file_path=r"\\192.168.1.153\文件中心模块\受控文件模块\有效图纸模块\PDF模块\组件\整机图"
import os
import pandas as pds
def check_file(file_path):
all_file = os.listdir(os.chdir(file_path))
files = []
for f in all_file:
if os.path.isdir(f):
files.extend(check_file(file_path+‘\\‘+f))
os.chdir(file_path)
else:
files.append(f)
return files
file_list = check_file(file_path)
#print(file_list)
#print(len(file_list))
data_files = pds.DataFrame(file_list)
data_files.to_excel("E:\精益工艺部\FileNames.xls")
#print(dataframe)
原文:https://www.cnblogs.com/centos-kang/p/14819443.html