AttributeError: 'dict' object has no attribute 'iteritems'

在python3.6中
运行
sortedClassCount = sorted(classCount.iteritems(), key=operator.itemgetter(1), reverse=True)
会出现AttributeError: 'dict' object has no attribute 'iteritems'的错误提醒
纠正错误的方法为:
iteritems变为items
sortedClassCount = sorted(classCount.items(), key=operator.itemgetter(1), reverse=True)
上一篇:AttributeError: 'dict' object has no attribute 'status_code'


下一篇:常见的磁盘I/O和网络I/O优化技巧