python3.9版本 - unsupported operand type(s) for +: ‘float‘ and ‘list‘ 解决方法

unsupported operand type(s) for +: ‘float’ and ‘list’ 不支持的操作数类型‘float’和‘list’

在用python3.9写程序时报错,在网上查了是因为将列表进行了加减操作,加import numpy 就行,但是有引入了numpy模块,最后发现写的函数最后返回值有值还有列表项,而后将函数进行了加减操作,所以解决办法有:
1.将函数返回值中的列表项删除
2.在运行函数时在函数末尾加“[num]”,即只要数值

猜你喜欢

转载自blog.csdn.net/qq_41968196/article/details/123964747
今日推荐