比对两个Excel列中的元素

import openpyxl
wb=openpyxl.load_workbook(r'e:\\玩家表.xlsx')
sheet=wb['Worksheet']
row_max=sheet.max_row
hw_ls=[]

for i  in  range(2,row_max+1):
    hw_ls.append(int(sheet.cell(row=i,column=1).value))


wb=openpyxl.load_workbook(r'e:\\d2.xlsx')
sheet=wb['Sheet1']
row_max=sheet.max_row
gx_ls=[]

for i  in  range(2,row_max+1):
    gx_ls.append(int(sheet.cell(row=i,column=1).value))
    pass
ls=[]
for j in gx_ls:
    if j in hw_ls:
        pass
    else:
        ls.append(j)
f=open('res1.txt','w')
f.write(str(ls))

 

posted @ 2020-05-13 04:04  余者皆可  阅读(219)  评论(0)    收藏  举报