在python 3中设置字符串变量的输入

在python 3中设置字符串变量的输入,python,string,python-3.x,input,Python,String,Python 3.x,Input,我正在将角色名称设置为用户提供的输入,并获得以下代码: characterOneName = str(input("What is the name of the first character? ")) print(characterOneName) 如果我尝试使用输入x运行它,则会出现以下错误: Traceback (most recent call last): File "C:/Users/Peter/Documents/ARCHIVES/2. School Work/Curren

我正在将角色名称设置为用户提供的输入,并获得以下代码:

characterOneName = str(input("What is the name of the first character? "))
print(characterOneName)
如果我尝试使用输入x运行它,则会出现以下错误:

Traceback (most recent call last):
  File "C:/Users/Peter/Documents/ARCHIVES/2. School Work/Current Year/Computing/notepad.py", line 1, in <module>
    characterOneName = str(input("What is the name of the first character? "))
  File "<string>", line 1, in <module>
NameError: name 'x' is not defined

怎么了?

您使用的是Python 2,而不是Python 3。

看起来您只使用了Python 2.x。2.7.3我的错我该如何让它在2.x上工作?使用原始输入。。。而不是大吵大闹…啊哈,谢谢你!现在工作:我已经作了回答,请考虑接受我的回答。