亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用Python將數據導入excel

使用Python將數據導入excel

郎朗坤 2021-07-19 16:23:27
在這段代碼中,我從兩個列表中名為“電子郵件”的 Excel 工作表中導入了數據:一種。清單 1灣 列表2處理該數據并將該數據存儲在最后兩個列表中:一種。final_list1灣 final_list2現在我想將這兩個最終列表中的數據存儲在同一個 excel 中的新工作表中,但我無法做到這一點請幫助我打?。╢inal_list2)后代碼未運行import xlrdimport xlwtfile_location = "E:/emails.xlsx"workbook = xlrd.open_workbook(file_location)sheet = workbook.sheet_by_index(0)list1 = [sheet.cell_value(r,0) for r in range(sheet.nrows)]type(list1)for r in range(sheet.nrows):        print(list1[r])final_list1 = [] for num in list1:    if num not in final_list1:        final_list1.append(num)print(final_list1)list2 = [sheet.cell_value(r,1) for r in range(sheet.nrows)]type(list2)for r in range(sheet.nrows):        print(list2[r])final_list2 = [] for num in list2:    if num not in final_list2:        final_list2.append(num)print(final_list2)final_list2 = [elem for elem in final_list2 if elem not in final_list1 ]print(final_list2)book = xlwt.Workbook(encoding="utf-8")sh = book.add_sheet("sh")i=1for r in range(10):    for col_index, item in enumerate(final_list2):        sh.write(i, col_index, item)      book.save("emails.xlsx")
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號