In Python2.*, input([prompt]) was equivalent to eval(raw_input([prompt])).

In Python3.*, input([prompt]) of Python2.* was removed and raw_input([prompt]) was renamed as input([[rompt]).


* Python 2.6에서 input() 함수 테스트하기

명령행프롬프트> python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "icense" for more information.
>>> x = input("Input a number: ")
Input a number: aaa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <module>
NameError: name 'aaa' is not defined


* Python 3.1에서 input() 함수 테스트하기

명령행프롬프트> python
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x = input("Input a number: ")
Input a number: aaa
>>> print x
  File "<stdin>", line 1
    print x
          ^
SyntaxError: invalid syntax
>>> print(x)
aaa
>>> type(x)
<class 'str'>
Posted by Scripter
,