比对两个Excel列中的元素

Posted 余者皆可

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了比对两个Excel列中的元素相关的知识,希望对你有一定的参考价值。

import openpyxl
wb=openpyxl.load_workbook(re:\\玩家表.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(re:\\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))

 

以上是关于比对两个Excel列中的元素的主要内容,如果未能解决你的问题,请参考以下文章