import pandas as pd df1 = pd.DataFrame({‘a’:[3,1],‘b’:[4,3]}) df2 = df1.copy() with pd.ExcelWriter(‘F:\python 入门 \ 数据 2\output.xlsx’) as writer: str1 = [‘a’,‘b’,‘c’,‘d’,‘e’,‘f’,‘g’,‘h’,‘i’, ‘j’,‘k’,‘l’,‘m’,‘n’,‘o’,‘p’,‘q’] for i in str1: name = str(i) df1.to_excel(writer, sheet_name= name) writer.save() writer.close()
不错,分享的小功能。
哈哈哈,自立更生,厉害 😁 😁
自问自答把。。。
网上找个例子。好用。
import pandas as pd
df1 = pd.DataFrame({‘a’:[3,1],‘b’:[4,3]})
df2 = df1.copy()
with pd.ExcelWriter(‘F:\python 入门 \ 数据 2\output.xlsx’) as writer:
str1 = [‘a’,‘b’,‘c’,‘d’,‘e’,‘f’,‘g’,‘h’,‘i’,
‘j’,‘k’,‘l’,‘m’,‘n’,‘o’,‘p’,‘q’]
for i in str1:
name = str(i)
df1.to_excel(writer, sheet_name= name)
writer.save()
writer.close()