标签:bsp nbsp 技术 with xls col frame python com
将一个列表数据写入output.xlsx的a,b,c……等sheet中
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()
结果:
此时每个sheet的内容都是一样的。
标签:bsp nbsp 技术 with xls col frame python com
原文地址:https://www.cnblogs.com/xiao02fang/p/12885476.html