import os
def find_file(file, cwl):
#cwl = os.path.abspath(cwl)
list_of_cwd = [x for x in os.listdir(cwl)]
print(list_of_cwd)
for i in list_of_cwd:
if os.path.isfile(i):
if file in i:
print(os.path.abspath(i))
elif os.path.isdir(i):
#cwl = os.path.join(cwl, i)
print(cwl)
find_file(file, os.path.join(cwl, i))
if __name__ == '__main__':
find_file('fi', '.')
31nm
输出是这样的:
求大神指教,为什么我找不到子文件夹里面的文件呢?