正确安装了pandas和openpyxl库。
可以通过在命令行中输入以下命令来检查:
pip show pandas
pip show openpyxl
可以使用pip安装
pip install pandas
pip install openpyxl#更新
pip install --upgrade pandas
pip install --upgrade openpyxl
保存excel
import pandas as pd
import tushare as tsts.set_token('注册用户的token')
pro = ts.pro_api()
df = pro.daily(ts_code='000001.SZ,600000.SH', start_date='20180701', end_date='20230718')
#df = ts.get_k_data('600080',ktype='D')
df1=df.head()
df2=df.tail()
writer = pd.ExcelWriter('output.xlsx', engine='openpyxl') # 这里需要指定引擎为openpyxl
df1.to_excel(writer,'Sheet1')
df2.to_excel(writer,'Sheet2')
#writer.save()
writer.close()