#两种方法
#!/usr/bin/env python
import os
dir='/root/sh'
'''
def fr(dir):
filelist=os.listdir(dir)
for i in filelist:
fullfile=os.path.join(dir,i)
if not os.path.isdir(fullfile):
if i == "1.txt":
#print fullfile
os.remove(fullfile)
else:
fr(fullfile)
'''
'''
def fw()dir:
for root,dirs,files in os.walk(dir):
for f in files:
if f == "1.txt":
#os.remove(os.path.join(root,f))
print os.path.join(root,f)
'''
转载于:https://blog.51cto.com/yayang/1651279