Python

[Python] 파이썬 에러관련

현석아뭐하니 2021. 3. 10. 11:49

• IndentationError

IndentationError: expected an indented block

- 들여쓰기 오류 

   → 들여쓰기를 해야 함 

 

• SyntaxError

SyntaxError: Missing parentheses in call to 'print'

- 구문 오류

   → 문법에 맞지 않음

 

NameError

NameError: name 'true' is not defined

- 이름 오류

   → 이름 'true'가 정의되지 않았음

 

 

• TypeError

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

- 유형 오류

   → 연산자+가 피연산자 유형 'int'와 'str'를 지원하지 않음

 

TypeError: can only concatenate str (not "int") to str

- 유형 오류

   → 문자열(str)은 단지 문자열하고만 연결할 수 있음

 

TypeError: 'int' object is not callable

- 유형 오류

   → 'int' 유형 객체는 호출할 수 없음

 

TypeError: meth2() takes 1 positional arguments but 2 were given

- 유형 오류

   → meth2()함수는 인자 1개를 전달받는데 2개가 전달되었음

 

 

ValueError

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

- 값 오류

   → 'a'는 int() 함수의 10진법으로 해석할 수 없음

 

ZeroDivisionError

ZeroDivisionError: division by zero

- 영 나눗셈 오류

   → 영(0)으로 나눌 수 없음

 

 

참고 

책 「 예제로 쉽게 배우는 파이썬 프로그래밍 _ 김상근 」 中 발췌