import pandas as pd
import os
path = r".\excel表格"
# 获取该目录下所有文件,存入列表中
fileList = os.listdir(path)
n = 0
all_df = pd.DataFrame()
for i in fileList:
file_path = path + os.sep + fileList[n]
df = pd.read_excel(file_path)
all_df = pd.concat([all_df, df])
n += 1
all_df.to_excel("all.xlsx", index=False)
标签:df,excel,合并,fileList,文件夹,pd,path,os
From: https://www.cnblogs.com/tiansz/p/16872785.html