import os
#获取文件
def all_path(dirname):
result = []
for maindir, subdir, file_name_list in os.walk(dirname):
for filename in file_name_list:
apath = os.path.join(maindir, filename)
result.append(apath)
return result
#筛选文件
def Separate_file(list):
result = []
filter = [".avi",".rmvb"]
for x in range(len(list)):
ext = os.path.splitext(list[x])[1]
if ext in filter:
result.append(list[x])
return result
def main(args):
path = "D:\\"
temp = all_path(path)
temp1 = Separate_file(temp)
print(temp1)
main(1)
文件扫描 文件筛选
最新推荐文章于 2022-01-06 21:45:21 发布