这个错误遇到得太多了,这次是因为企图直接将'float' object转换为list:
total_energys.append(list(total_energy))
这里的total_energy的类型就是float。
直接将其append就行:
total_energys.append(total_energy)
本文解决了一个常见的编程问题,即尝试直接将浮点数对象转换为列表时出现的错误。正确的做法是直接将浮点数追加到列表中,而非先转换其类型。
这个错误遇到得太多了,这次是因为企图直接将'float' object转换为list:
total_energys.append(list(total_energy))
这里的total_energy的类型就是float。
直接将其append就行:
total_energys.append(total_energy)

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