示例展示
代码
import os
import pandas as pd
folder_path =r"C:\Users\admin\Desktop\excelfile"
extension="xlsx"
files = [file for file in os.listdir(folder_path) if file.endswith('.' + extension)]
for file in files:
filepath = os.path.join(folder_path, file)
print(filepath)
df = pd.read_excel(filepath)
print(df.head())