0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonエラーまとめ

Last updated at Posted at 2018-09-28

'int' object is not callable :

原因 : classオブジェクトの呼び出しのとき、呼び出す対象が整数のときに()を付けるとエラーとなる。
解決策 : ()を外す


from datetime import datetime 
t = datetime.now()
# ty = t.year()                #エラーになる
ty = t.year 

invalid literal for int() with base 10: ''

''を整数に変換できない。


lastday[i] = int((lastday[i].split(","))[0])

unsupported operand type(s) for -: 'str' and 'int'

マイナス(-)という演算子(operand)に対して間違った対象(この場合、文字列と整数)を用いていたため。直すには、int関数などを用いて、文字列と文字列相手にするか、整数と整数相手に行う。


step = "1"
step = step - 1
# 直すにはint(step)を2行目に挟めばよい

list indices must be integers or slices, not tuple


D = np.array([[1,v1,v1,0,0,0],[v1,1,v1,0,0,0],[v1,v1,1,0,0,0] \
              [0,0,0,v2,0,0],[0,0,0,0,v2,0],[0,0,0,0,0,v2]])

# np arrayに対応していない形式になっている。(一行目の,が不足している)
# 以下の形にすればよい(リスト形式になる。)
# D = np.array([[1,v1,v1,0,0,0],[v1,1,v1,0,0,0],[v1,v1,1,0,0,0], \
#              [0,0,0,v2,0,0],[0,0,0,0,v2,0],[0,0,0,0,0,v2]])

'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

os.chdir("")でのエラー
不要なスペースや不適切な区切り文字がディレクトリの名前に入っていることが原因だと思われる.区切り文字\\\など,別の文字にすると解決できることがある.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?