判断两个Excel表内容是否存在不同数据 【记录】
作者:互联网
def contrast_excel():
l_p = [] # 小表
wb_pri = xlrd.open_workbook('/Users/bunsuketake/Desktop/台账.xls') # 打开原始文件
sheet1 = wb_pri.sheet_by_name("Sheet1")
nrows = sheet1.nrows
wb_tar = xlrd.open_workbook('/Users/bunsuketake/Desktop/台账的副本.xls') # 打开目标文件
sheet2 = wb_tar.sheet_by_name("Sheet1")
nrows2 = sheet2.nrows
for i in range(1, nrows):
test01 = sheet1.row_values(i)
for j in range(1, nrows2):
test02 = sheet2.row_values(j)
l_p.append(test02)
if test01 not in l_p:
return False
else:
return True
标签:判断,wb,tar,记录,Excel,nrows,sheet1,sheet2,台账 来源: https://www.cnblogs.com/yitiaoxianyu01/p/15643212.html