|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
nam={0: {1: 99, 2: 89, 3: 79}, 1: {1: 98, 2: 88, 3: 78}, 2: {1: 97, 2: 87, 3: 77}}
nameno={1: 'fanghao', 2: 'zhou', 3: 'xu'}
for no in nameno.keys():
print("{:<5}:".format(nameno[no]),end="")
sum=0
for subject_no in nam:
sum+=subject_no[no]
print("{}:{:>3}".format(subjects[subject_no],subject_no[no]),end="")
print("总分:{:>3},平均:{:.2f}".format(sum,sum/float(len(subject_no))))
>>>fanghao:Traceback (most recent call last):
File "<pyshell#3>", line 5, in <module>
sum+=subject_no[no]
TypeError: 'int' object is not subscriptable
出错了这个程序应该怎么改 |
|