【E-10】object of type cannot be safely interpreted as an integer.(numpy)


錯誤提示位置

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解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM