pythonTypeError:|pythonTypeError: 'float' object cannot be interpreted as an integer
运行代码(python2)
number = 254 / thread_num
出现
TypeError: 'float' object cannot be interpreted as an integer
原因:在python2,‘/’ 只留下了整数部分,去掉了小数,是int型。而在 python3里,‘/’ 的结果是真正意义上的除法,结果是float型。所以便出现了TypeError: ‘float’ object cannot be interpreted as an integer
【pythonTypeError:|pythonTypeError: 'float' object cannot be interpreted as an integer】将代码改为(python3)
number = 254 // thread_num
python2用‘/’,python3用‘//’
推荐阅读
- EffectiveObjective-C2.0|EffectiveObjective-C2.0 笔记 - 第二部分
- iOS面试题--基础
- performSelectorOnMainThread:withObject:waitUntilDone:参数设置为NO或YES的区别
- ATAN2根据xy坐标计算角度
- Objective-c
- Floating|Floating dream
- 在Objective-C的Category中使用属性的懒加载
- 微信小程序____CSS篇之定位(position)及浮动(float)
- IE|IE 11 处理 object-fit: contain 问题
- Python|Python TypeError: 'module' object is not callable 原因分析