본문 바로가기
반응형

디버깅8

[파이썬] 파이썬 에러 ValueError: invalid literal for int() with base10: '4.3' 안녕하세요 한주현입니다. 오늘은 파이썬 형변환에서 발생하는 오류인 ValueError: invalid literal for int() with base 10: '4.3' 에 대하여 알아보겠습니다. 파이썬에서는 형변환이 간단합니다. 문자형으로 바꿀 때는 str()정수형으로 바꿀 때는 int()실수형으로 바꿀 때는 float()를 각각 사용합니다. 문자열을 정수로 변환123>>> a = '10'>>> int(a)10cs 문자열을 실수로 변환123>>> b = '4.3'>>> float(b)4.3cs 정수를 문자열로 변환123>>> c = 7>>> str(c)'7'cs 실수를 문자열로 변환123>>> d = 2.71>>> str(d)'2.71'cs 문제 상황 ValueError: invalid literal .. 2017. 11. 1.
[파이썬] 파이썬 에러 SyntaxError: Missing parentheses in call to 'print' 안녕하세요 한주현입니다. 오늘은 파이썬2에서는 잘 실행 되는데 파이썬3에서 실행하면 발생하는 오류 중 하나인, SyntaxError: Missing parentheses in call to 'print' 에 대하여 알아보겠습니다. 문제 상황 SyntaxError: Missing parentheses in call to 'print' 파이썬3가 나오고 파이썬2는 legacy(유물)로 말씀하시는 귀도 선생님의 말씀을 새겨 듣고 파이썬3으로 옮겨 오기 위해 파이썬3을 설치 및 기존 코드를 실행해보니 아래와 같은 오류 발생 ㅋㅋ 12345$ python3 helloworld2.py File "helloworld2.py", line 1 print "hello world" ^SyntaxError: Missing p.. 2017. 11. 1.
[파이썬] 파이썬 에러 IndentationError: expected an indented block 안녕하세요 한주현입니다. 오늘은 파이썬 스크립트 작성 시 자주 보게되는 오류 중 하나인, IndentationError: expected an indented block 에 대하여 알아보겠습니다. 문제 상황 IndentationError: expected an indented block 기분 좋게 스크립트를 아래와 같이 작성한 다음 실행을 시켰더니.. 1234def hello():print("Hello World!") hello()cs 아래와 같이 오류가 났습니다.. ㅠㅠ 12345$ python helloworld.py File "helloworld.py", line 2 print("Hello world") ^IndentationError: expected an indented blockcs 무슨 일일.. 2017. 11. 1.
[파이썬] 파이썬 에러 IndexError: list index out of range 안녕하세요 한주현입니다. 오늘은 파이썬 스크립트 작성 시 자주 보게되는 오류 중 하나인, IndexError: list index out of range 에 대하여 알아보겠습니다. 문제 상황 IndexError: list index out of range 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >>> lst = [1,2,3] >>> lst [1, 2, 3] >>> lst[0] 1 >>> lst[1] 2 >>> lst[2] 3 >>> lst[3] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range >>> Colored by Color Scripter cs 파이썬 뿐만 아니.. 2017. 11. 1.
반응형