我只是在python中做一些练习我试图打印输入可变但我得到这个错误:
Traceback (most recent call last):
File "mva1.py", line 1, in <module>
name = input("what is your name?")
File "<string>", line 1, in <module>
NameError: name 'Francis' is not defined
这是我的代码:
name = input("what is your name?")
if name is "Francis":
print "Welcome"
我也这样做了:
name = input("what is your name?")
print name
在运行它时,我输入了我的名字并收到了这个错误:
Traceback (most recent call last):
File "C:/Users/DELL/Desktop/frankscute's/Practices/mva1.py", line 1, in <module>
name = input("what is your name?")
File "<string>", line 1, in <module>
NameError: name 'Francis' is not defined
我在PyCharm IDE上使用Python 2.7
答案 0 :(得分:0)
Python 2.7使用raw_input
而非input
。使用Python 3.2 for input
来获取用户输入。 (在这种情况下)
name = raw_input("what is your name?")
if name is "Francis":
print "Welcome"# your code goes here