默认路径为当前目录,递归查找
import osdef find_file(text, path='.'): for fd in os.listdir(path): fd_fullpath = os.path.join(path, fd) if os.path.isfile(fd_fullpath) and fd.find(text) != -1: print(fd_fullpath) elif os.path.isdir(fd_fullpath): find_file(text, fd_fullpath)find_file('xml')
结果:
.\.idea\inspectionProfiles\profiles_settings.xml .\.idea\misc.xml .\.idea\modules.xml .\.idea\workspace.xml .\aa.xml.txt
为什么排版全乱了?
Sign in to make a reply
freedempire
默认路径为当前目录,递归查找
结果: