30 lines
564 B
Python
30 lines
564 B
Python
|
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
# 找到指定后缀的文件
|
||
|
def find_type(path:str,fix:str):
|
||
|
dlist=os.listdir(path)
|
||
|
file_list=[]
|
||
|
for i in dlist:
|
||
|
ps=os.path.join(path, i)
|
||
|
if os.path.isdir(ps):
|
||
|
# file_list+=find_type(ps,fix)
|
||
|
pass
|
||
|
else:
|
||
|
if(ps[-len(fix):]==fix):
|
||
|
file_list.append(ps)
|
||
|
return file_list
|
||
|
|
||
|
|
||
|
# 第一个参数是扫描路径,第二个参数是文件类型
|
||
|
if __name__ == "__main__":
|
||
|
|
||
|
f_list=find_type(sys.argv[1],sys.argv[2])
|
||
|
for item in f_list:
|
||
|
print(item)
|
||
|
|