文章詳情頁(yè)
Python使用Excel將數(shù)據(jù)寫(xiě)入多個(gè)sheet
瀏覽:7日期:2022-07-25 13:57:01
將一個(gè)列表數(shù)據(jù)寫(xiě)入output.xlsx的a,b,c……等sheet中
import pandas as pddf1 = pd.DataFrame({’a’:[3,1],’b’:[4,3]}) df2 = df1.copy()with pd.ExcelWriter(’F:python入門(mén)數(shù)據(jù)2output.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()
結(jié)果
此時(shí)每個(gè)sheet的內(nèi)容都是一樣的。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
標(biāo)簽:
python
相關(guān)文章:
排行榜
