파이썬(Python) 2.x와 3.x 버전의 print 사용 차이

조회 3,237 · 댓글 0
강철지그강철지그작성자2017년 7월 11일
테스트 프로그램


myList = [1, 2, 3]

print myList


1. 파이썬 2


Python 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


실행


$ python list.py

[1, 2, 3]



2. 파이썬 3


Python 3.6.1 (default, Jul 7 2017, 15:41:29)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>


실행


$ python3 list.py

File "list.py", line 2
print myList
^
SyntaxError: Missing parentheses in call to 'print'


오류 발생

print myList -> print(myList) 로 수정 후 재실행


$ python3 list.py

[1, 2, 3]

로그인 후 답글을 남길 수 있습니다.