Python3报错:TypeError: unsupported operand type(s) for /: 'dict_values' and 'int'
报错原因:
-
In python3,
dict.valuesreturns adict_valuesobject, which is not alistortuple. 
解决方法:Try coercing that into a list.

本文详细解析了Python3中处理字典时常见的TypeError错误,即不支持'dict_values'类型与'int'进行除法运算的问题。文章指出,在Python3中,dict.values()返回的是dict_values对象,而非列表或元组,这可能导致运算错误。为解决此问题,建议将dict_values转换为列表。
dict.values returns a dict_values object, which is not a list or tuple.

1万+

被折叠的 条评论
为什么被折叠?