定义
import os
def gci(filepath):
files = os.listdir(filepath)
for fi in files:
fi_d = os.path.join(filepath,fi)
if os.path.isdir(fi_d):
gci(fi_d)
else:
file=os.path.join(filepath,fi_d)
num=file.rfind('.')
result=file[num+1:]
if result not in Result:
Result.append(result)
return Result
调用
Result=[]
gci('f:\example')
结果展示