- import glob,os
- def fun(path):
- for fn in glob.glob(path + os.sep + '*'):
- if os.path.isdir(fn):
- fun(fn)
- else:
- if "/archive/" in str(fn) and os.path.isfile(fn):
- print "going to delete " + fn
- try:
- os.remove(fn)
- except:
- pass
- fun(r'/.../logs')
- #该片段来自于http://www.codesnippet.cn/detail/110220148687.html
来源: http://www.codesnippet.cn/detail/110220148687.html