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

  • jeeg
    (강철지그)
  • jeeg's Avatar 이 글의 작성자
  • Offline
  • Junior
  • Junior
더보기
11 Jul 2017 09:39 - 11 Jul 2017 09:40 #2349 작성자: jeeg
jeeg 님의 글: 파이썬(Python) 2.x와 3.x 버전의 print 사용 차이
테스트 프로그램

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]
Time to create page: 0.049 seconds
Powered by Kunena Forum