- # -*- coding: utf8 -*-
- '''
- Created on 2012-9-10
- @author: tangyao
- '''
- import os
- def delfile(paths):
- if os.path.isfile(paths):
- try:
- os.remove(paths)
- except:
- pass
- elif os.path.isdir(paths):
- for file in os.listdir(paths):
- # print itemf
- subpath=os.path.join(paths,file)
- # print subpath
- delfile(subpath)
- try:
- os.rmdir(paths)
- except:
- pass
- print os.getcwd()
- #该片段来自于http://www.codesnippet.cn/detail/170620134063.html
来源: http://www.codesnippet.cn/detail/170620134063.html