赞
踩
import os def test_findfile(directory, fileType, file_prefix): fileList = [] for root, subDirs, files in os.walk(directory): for fileName in files: if fileName.endswith(fileType) and fileName.startswith(file_prefix): fileList.append(os.path.join(root, fileName)) return fileList def list_filess(): dir="C:\\Git\\moxyrulesnewui_python1\\org\\adv\\rules\\UIAutomation\\testcase\\" fileType=".py" # python 文件 file_pre="test_" # 文件以tes_开头 fileList = test_findfile(dir, fileType,file_pre) # print(fileList) for item in fileList: print(item)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。