求教各位大神帮解答
本帖最后由 火石 于 2020-10-27 09:11 编辑已知df1,df2,选出df2中“日期”和“代号”列与df1都相同的行,组成df3
请问用python怎么写 我顶 from openpyxl import load_workbook
from openpyxl import Workbook
wb3 = Workbook()#创建输出文件对象
ws3 = wb3.active
wb1 =load_workbook("openpyxl_1.xlsx")#打开excel
ws1 = wb1.active#打开当前活跃的sheet
dict1={}
for row in ws1.rows:
dict1.value)+row.value]=1
wb2 =load_workbook("openpyxl_2.xlsx")#打开excel
ws2 = wb2.active#打开当前活跃的sheet
i=1
for row in ws2.rows:
if str(row.value)+row.value in dict1:
ws3['A'+str(i)] = row.value
ws3['B'+str(i)] = row.value
ws3['C'+str(i)] = row.value
i+=1
wb3.save('openpyxl_3.xlsx')
openpyxl_1.xlsx
20200501 AA
20200502 BB
openpyxl_2.xlsx
20200501 AA 12
20200502 BB 13
20200501 MM 14
20200502 MM 15
openpyxl_3.xlsx
20200501 AA 12
20200502 BB 13
fall_bernana 发表于 2020-10-27 10:37
可以,我也去试一试看哪里可以加点自己的想法。 应该悬赏 顶一下 哦回帖居然有鱼币拿
页:
[1]