pythonExcel两表中姓名信息对比
Posted nfcf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pythonExcel两表中姓名信息对比相关的知识,希望对你有一定的参考价值。
Excel两表中姓名信息对比
Excel两表中姓名信息对比,及写入对比结果:
# -*- coding: UTF-8 -*- from openpyxl import load_workbook from openpyxl import Workbook # 以‘xxx花名册.xlsx‘为准 yuanbook = load_workbook(filename=‘xxx花名册.xlsx‘,read_only=True) objectbook = load_workbook(‘花名册0523.xlsx‘) yuansheet = yuanbook[‘X‘] objectsheet = objectbook[‘XXX‘] for i in range(4,761): for j in range(4,761): cell_yuansheet = yuansheet.cell(row=i, column=3) cell_objectsheet = objectsheet.cell(row=j, column=3) yuancell_s = str(cell_yuansheet.value) objectcell_s = str(cell_objectsheet.value) print(‘正在处理‘,i,j) if objectcell_s == yuancell_s: result_cell = objectsheet.cell(row=i, column=18) result_cell.value = ‘存在‘ print(f‘正好是{i}和{j}‘) break else: continue objectbook.save(‘花名册0523.xlsx‘)
以上是关于pythonExcel两表中姓名信息对比的主要内容,如果未能解决你的问题,请参考以下文章