Python处理Excel数据

1、https://zhuanlan.zhihu.com/p/93244214

--------------------下面是自己随便写得

import openpyxl

# 打开一张表
wb = openpyxl.load_workbook('D:\\test\\2022.xlsx')

ws = wb.active


for i in range(1, 18):
    sum_total = 0
    if i == 1:
        row3 = ws[i]
        for cell in row3:
            if type(cell.value) == int:
                sum_total += cell.value
            print(cell.value, end=' ')
        print()
    else:
        row3 = ws[i]
        for cell in row3:
            if type(cell.value) == int or type(cell.value) == float:
                sum_total += cell.value
            if cell.value is not None:
                print(cell.value, end=' ')
        print(sum_total)

上面的例子就是统计,每个人的总成绩。

猜你喜欢

转载自blog.csdn.net/weixin_54217632/article/details/120205552