import os
def get_file_name(file_dir,file_type):
L=[]
for root, dirs, files in os.walk(file_dir):
for file in files:
if os.path.splitext(file)[1] == file_type:
L.append(os.path.join(root, file))
return L
调用
L=user_func.get_file_name('c:\\mypython\\test','.xlsx')
==============
takes 1 positional argument but 2 were given