输入的Python代码错误

时间:2014-01-28 03:54:46

标签: python-3.x input

我输入代码有问题,这是代码的出现

Hello World The Game
Youtube: www.youtube.com/user/creepermoon2/
Current Game Version 0.1 Alpha
What Is your name?Josef

Traceback (most recent call last):
File "C:/Python27/Game.py", line 25, in <module>
Name = input ("What Is your name?")
File "<string>", line 1, in <module>
NameError: name 'Josef' is not defined

代码是

#This is a simple video game created by CreeperMoon2
#PROGRAMING NOTES

#to wait use time.sleep(SECONDS)
#
#
#
#

#VARIABLES
GameVrsn = 0.1
#VARIABLES

#IMPORTED CLASSES
import time
import os
#IMPORTED CLASSES

print "Hello World The Game"
time.sleep(5)
print "Youtube: www.youtube.com/user/creepermoon2/"
time.sleep(5)
print ("Current Game Version 0.1 Alpha")
time.sleep(5)
Name = input ("What Is your name?")

我真的不知道如何解决这个问题我从python 3的教程中得到了这个可能不正确但我不知道如何修复它请快速回复

1 个答案:

答案 0 :(得分:1)

虽然你认为你正在运行3.x解释器,但实际上你正在使用2.x解释器,因为

print "Hello World The Game"

是python 3的错误。(print是一个函数:print("Hello World The Game")

在Python 2中,您应该使用raw_input而不是input

您的代码是Python 2和3语法的混合,并且在没有错误的情况下都无法正常工作。