标签: python floating-point sum
我上面有来自mongodb的浮动数字,并尝试用下面的代码加总数字并得到错误。
unsupported operand type(s) for +: 'int' and 'str'
错误: NPM_CONFIG_PRODUCTION=false
NPM_CONFIG_PRODUCTION=false
答案 0 :(得分:0)
document['Price']显然包含字符串和数字的混合。您应该首先将所有元素转换为数字。
document['Price']
Price = [float(x) for x in document['Price']]