你创建的字典记得把题目编号(tno)和分数(a_answer/b/c) 都用int()转为整数再存入字典作为键和值,然后遍历考生提交的分数字符串即可。
s = 0 for i in range(20): s += dic_t[i+1][d[i]]