添加一些可能有用的python脚本
This commit is contained in:
29
list_files.py
Executable file
29
list_files.py
Executable file
@@ -0,0 +1,29 @@
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user