from openpyxl import load_workbook
class KnowledgeComplete:
def __init__(self, excel_name):
self.excel_name = excel_name
self.workbook = load_workbook(excel_name)
self.worksheet = self.workbook['sheet1']
def run(self):
for row in range(2,self.worksheet.max_row):
if (
not self.worksheet.cell(row=row, column=3).value
) and (
self.worksheet.cell(row=row, column=2).value
):
self.worksheet.cell(row=row, column=3).value = "无"
print(row)
self.workbook.save(self.excel_name)
if __name__ == '__main__':
k = KnowledgeComplete("pass.xlsx")
k.run()
|