已解决ypeError: ‘float‘ object cannot be interpreted as an integer

已解决ypeError: ‘float’ object cannot be interpreted as an integer

在这里插入图片描述

报错问题

之前在工作中遇到过这个坑,记录一下问题以及解决方法,不一定针对所有情况都能用,但是可以供大家参考。
问题描述如下:

ypeError: ‘float’ object cannot be interpreted as an integer
类型错误:“float”对象不能解释为整数

在这里插入图片描述

解决方法

在这里插入图片描述
python2和python3中运算符的区别
查看代码中是否含有/,
python3的/结果含有浮点数!
python2中的/等价于python3的//
在python3中,//表示取整除 - 返回商的整数部分(向下取整)

PS

有问题评论区留言即可

猜你喜欢

转载自blog.csdn.net/weixin_50843918/article/details/130417586