LoginSignup
7
7

More than 3 years have passed since last update.

Pythonのエラー対処法

Last updated at Posted at 2019-04-21

対処法

  1. 一番下を見る
  2. 行を見る
  3. 対処

コード

  • ImportError: No module named
    • もしかしたらpip内にあるからインストールしましょう. バージョンに注意
  • IndexError: list index out of range
    • 存在しないから, どこかで誤作動起こしてるかも.
  • TypeError: takes exactly (x) arguments ((?) given) (x=必要な引数の数 ?=与えた引数の数)
    • 引数が足りない.
  • NameError: name '-' is not defined
    • 関数内だったら global - などをやって見るのもいいかも. globalの使い方
  • ValueError: invalid literal for int() with base 10
    • 変数でやってるなら中身が文字かも. プログラムの流れをよく見てみよう
  • SyntaxError: invalid syntax
    • しっかり文を見てみよう
  • AttributeError: --- instance has no attribute
    • クラスの中に, その関数はないよと言っている.
  • AttributeError: class --- has no attribute '---'
    • 上のエラーとほぼ同じ
  • IndentationError: expected an indented block
    • スペースとタブの併用は無理. OK?
  • TypeError: can only concatenate list (not "int") to list
    • str+int, list+str などをやってないか?
  • KeyError  - IndexErrorと同じように存在しないやつ

公式ドキュメント

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