网上有一中出现的情况如下:

batch = 200for x in range(len(order_nos) / batch + 1): # do something

此代码在python2下运行正常但是在python3下面运行会出现问题;

原因在于两个版本下对float的处理方法不同,python2下在运行/的时候产生的结果会自动忽略小数,直接取整数,而python3中 是会保留小数点的所以产生了错误

其次,对于

y_linear=x+(5.)*np.random.randn(14.)
这个代码片也会报这个错误原因是在python3中randn里的14.的小数点无法被自动忽略转换成整型导致了错误,所以要根据情况更换使用方法。randn()中的参数一定是正整数

python-Error Message: 'float' object cannot be interpreted as an integer相关推荐

  1. 生成浮点数列表:Python range():TypeError: ‘float‘ object cannot be interpreted as an integer

    生成浮点数列表:Python range():TypeError: 'float' object cannot be interpreted as an integer 目录 Python range ...

  2. 成功解决TypeError: ‘float‘ object cannot be interpreted as an integer

    问题描述: 在使用Python的for w in range(0.0, 4.1, 0.1):时遇到报错: TypeError: 'float' object cannot be interpreted ...

  3. 已解决实现心型图案时报错TypeError: ‘float‘ object cannot be interpreted as an integer

    已成功解决实现心型图案时使用range在生成数列时,报错TypeError: 'float' object cannot be interpreted as an integer 问题描述 我在使用p ...

  4. 成功解决TypeError: 'float' object cannot be interpreted as an integer

    成功解决TypeError: 'float' object cannot be interpreted as an integer 目录 解决问题 解决思路 解决方法 解决问题 TypeError: ...

  5. python range函数报错:TypeError: ‘float‘ object cannot be interpreted as an integer

    原因是range只能生成整数,不能生成float类型,使用 numpy的 arange函数来解决: import numpy as npfor i in np.arange(0.1,0.5,0.05) ...

  6. 成功解决TypeError: ‘float’ object cannot be interpreted as an index

    成功解决TypeError: 'float' object cannot be interpreted as an index 目录 解决问题 解决思路 解决方法 解决问题 TypeError: 'f ...

  7. 【python】解决TypeError: ‘str‘ object cannot be interpreted as an integer

    当用python的input输入一个数字时 其格式默认为string格式 所以要用int()转换为int格式 比如 import math def opgg():     # x = input(&q ...

  8. 'numpy.float64' object cannot be interpreted as an integer

    'numpy.float64' object cannot be interpreted as an integer fp=open(filename,'rb') blk_size = prod(di ...

  9. TypeError: 'str' object cannot be interpreted as an integer

    TypeError: 'str' object cannot be interpreted as an integer python3 ,pycharm中运行 page = input('please ...

  10. 训练数据出现TypeError: 'numpy.float64' object cannot be interpreted as an integer错误

    问题背景: 用tensorflow训练自己的数据的时候,训练一段时间后,出现TypeError: 'numpy.float64' object cannot be interpreted as an ...

最新文章

  1. web前端项目--用hbuilder调试app项目
  2. 学术写作利器——LaTeX入门笔记整理(不定期更新,附加使用心得)
  3. LAN远程重启server安全方法
  4. Java数据库篇7——数据库设计
  5. c语言宏 转换字符串,c预处理程序-如何从C宏的值生成char字符串?
  6. 【Qt教程】3.1 - Qt5 event事件、Label控件的鼠标事件捕获
  7. WebSocket了解一下
  8. cocos2d cocostudio
  9. 计算机网络自顶向下WireShark实验:ICMP
  10. Hive教程-详细全部
  11. linux下使用wakeonlan远程唤醒报错:Network is unreachable at /usr/bin/wakeonlan line 126.
  12. pandas 保存Excel 解决科学计数法问题
  13. 走向全民开发,低代码重塑企业数字化生产力 | 爱分析报告
  14. 服务器功耗计算器_无服务器在您的用例中便宜吗? 用这个计算器找出答案。
  15. php首字母改大写,php实现字符串首字母转换成大写的方法
  16. 乐视2 usb计算机连接,乐视 LetvX620 开启USB调试模式
  17. 机械硬盘升级固态硬盘
  18. springboot+ssm+jsp大学生社团活动报名管理系统java
  19. 古希腊神话故事3 :丢卡利翁和皮拉
  20. 12个固态硬盘优化技巧,延长固态硬盘使用寿命

热门文章

  1. VMware 虚拟机运行卡慢的解决办法
  2. Asp.NetCore远程自启动、重启、关闭实现
  3. react中IOS手机里面两个input同时存在时,聚焦focus失效解决办法
  4. AC日记——贪婪大陆 洛谷 P2184
  5. CentOS 通过yum来升级php到php5.6
  6. ubuntu下安装python的gevent模块遇到的一个问题
  7. Emberjs学习之路(一)
  8. SpringBoot与缓存使用及原理(上)
  9. JavaWeb三大组件小结
  10. SpringBoot中静态资源配置