python中的列表数据如何保存到excel

时间:2024-10-15 03:53:41

1、安装Pandas:通过Python环境自带的Pip包管理工具就可以安装Pandas模块,命如下:$ pip install pandaspandas模块操作excel依赖xlwt模块,所以也必须安装:$ pip installxlwt具体如图

python中的列表数据如何保存到excel

2、导入模块,python代码如下:import pandas as pd

python中的列表数据如何保存到excel

4、将dataframe保存到excel文件中python代码如下:dataframe.to_excel('/home/list.xls')

python中的列表数据如何保存到excelpython中的列表数据如何保存到excel

6、完整代码如下:import pandas as pdlist=['value1','value2','value3'稆糨孝汶;]dataframe = pd.DataFrame(list)print(dataframe)dataframe.to_excel('/home/hzd/list.xls')

© 手抄报圈