字典没有下标的概念了,是使用key进行索引, 把代码改成这样就可以了: for key in record.keys(): record[key] += 1
print(len(dict.keys()))