name = input("what is your name ?")
what is your name ?harsha
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
name = input("what is your name ?")
File "<string>", line 1, in <module>
NameError: name 'harsha' is not defined
>>> name = input("what is your name?")
what is your name?"harsha"
>>> print(name)
harsha
raw_input ()
raw_input() '函数不会求值,它只会读取你输入的内容。
例子:
name = raw_input("what is your name ?")
what is your name ?harsha
>>> name
'harsha'
例子:
name = eval(raw_input("what is your name?"))
what is your name?harsha
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
name = eval(raw_input("what is your name?"))
File "<string>", line 1, in <module>
NameError: name 'harsha' is not defined