作成
編集する
TypeError: slice indices must be integers or None or have an __index__ method
python
エラー
以下のようなソースでエラーがでました。
pylab.plot(fs[0:n/2], a[0:n/2])
TypeError: slice indices must be integers or None or have an __index__ method
これで治ります。
pylab.plot(fs[0:n//2], a[0:n//2])
理由は python3では / は実数。 // は整数です。
Python3 の除算
x = 5/2 #結果 2.5 x = 5//2 #結果 2
LOGIN
Facebook
Twitter
Google
AUTHOR
@mikomiko
最終更新日 2018/09/17
FAVORITE
LINK TAG
<a href="http://wakatta.xyz/i202/" target="_blank">TypeError: slice indices must be integers or None or have an __index__ method - wakatta</a>
記法を見る
1737000135