openpyxl import load_workbook
path = 'D:/sample.xlsx'
wb = load_workbook(path)
ws = wb['Sheet']
# 印出每個人的總分
for row in list(ws.rows)[1:]: # 拜訪標題列外的每一列
data = [cell.value for cell in row] # 取得該列中每一儲存格的值
print(data[0], sum(data[1:]))
# 印出每科的總分
for col in list(ws.columns)[1:]: # 拜訪標題行外的每一列
data = [cell.value for cell in col] # 取得該行中每一儲存格的值
print(data[0], sum(data[1:]))
wb.save(path)