Discuss / Python / 如果用os.path.walk算不算作弊啊

如果用os.path.walk算不算作弊啊

Topic source

玖道

#1 Created at ... [Delete] [Delete and Lock User]
在此插入代码

import os.path

def check_files((lst, keyword, path), dirname, files): for file in files: file_name = os.path.join(dirname,file) if keyword in file and os.path.isfile(file_name): lst.append(os.path.relpath(file_name,path))

path = os.path.abspath('') files_list = [] os.path.walk(path, check_files, (files_list, 'ex', path)) for i in files_list: print(i)


  • 1

Reply