wendi-cai

在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径:

import os
testfiles = []
testfilepaths = []
L = len(os.path.abspath(\'.\'))

def searchfile(path):
    for item in os.listdir(path):
        if os.path.isdir(os.path.join(path, item)):
            searchfile(os.path.join(path, item))
        else:
            if \'test\' in item:
                print(item, path[L:])

searchfile(os.path.abspath(\'.\'))

分类:

技术点:

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-01-07
猜你喜欢
  • 2022-01-30
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案