Discuss / Python / 作业第二题

作业第二题

Topic source

freedempire

#1 Created at ... [Delete] [Delete and Lock User]

默认路径为当前目录,递归查找

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

freedempire

#2 Created at ... [Delete] [Delete and Lock User]

为什么排版全乱了?


  • 1

Reply