待读取文件预览:
![](https://i-blog.csdnimg.cn/blog_migrate/e9ae8b8de59cf5342f32c221798c3d6c.png)
读取excel代码:
import pandas as pd
file_path = r'C:\Users\123\Desktop\pandastest\example.xlsx'
df = pd.read_excel(file_path, sheet_name=0, header=0, skipfooter=0)
print(df)
输出结果:
导出excel代码:
import pandas as pd
file_path = r'C:\Users\123\Desktop\pandastest\example.xlsx'
df = pd.read_excel(file_path, sheet_name=0, header=0, skipfooter=0)
print(df)
df.to_excel(r'C:\Users\123\Desktop\pandastest\output.xlsx', engine='openpyxl', index=False)
导出结果:
![](https://i-blog.csdnimg.cn/blog_migrate/c3062a506926afcd04f4f96da68148b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9cdd55bd682ccff761117fea2055631.png)