首页 > 其他 > 详细

【E-10】object of type <class 'float'> cannot be safely interpreted as an integer.(numpy)

时间:2020-08-08 22:24:13      阅读:242      评论:0      收藏:0      [点我收藏+]

错误提示位置

freqs = np.linspace(0, sample_rate/2, nfft/2 + 1)

? ?

可能原因

1numpy版本问题

2Python版本问题:在python2,/只留下了整数部分,去掉了小数,是int型。而在python3里,/的结果是真正意义上的除法,结果是float型。所以便出现了Error Message: ‘float‘ object cannot be interpreted as an integer。

? ?

解决方法

1、numpy 1.18.2 -> numpy 1.17.0

2、修改符号:freqs = np.linspace(0, sample_rate/2, nfft//2 + 1)

? ?

本次采用2解决

【E-10】object of type <class 'float'> cannot be safely interpreted as an integer.(numpy)

原文:https://www.cnblogs.com/yifanrensheng/p/13460540.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!