Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python原始输入不工作_Python_Python 3.x - Fatal编程技术网

Python原始输入不工作

Python原始输入不工作,python,python-3.x,Python,Python 3.x,下面是我的代码: randomOne = int(str(raw_input('Enter the first number.'))) randomTwo = int(str(raw_input('Enter the second number.'))) 我总是收到以下错误消息: Traceback (most recent call last): File "C:/Users/*****/Desktop/Pythons/randomNumberGenerator.py", line

下面是我的代码:

randomOne = int(str(raw_input('Enter the first number.')))
randomTwo = int(str(raw_input('Enter the second number.')))
我总是收到以下错误消息:

Traceback (most recent call last):
    File "C:/Users/*****/Desktop/Pythons/randomNumberGenerator.py", line 5, in <module>
randomOne = int(str(raw_input('Enter the first number.')))
NameError: name 'raw_input' is not defined
回溯(最近一次呼叫最后一次):
文件“C:/Users/*****/Desktop/Pythons/randomNumberGenerator.py”,第5行,在
randomOne=int(str(原始输入('输入第一个数字'))
NameError:未定义名称“原始输入”

如果我能得到一些帮助,我一点也不明白发生了什么事?

如果您使用的是python 3,它没有
原始输入,请改用。

您使用的是什么版本原始输入
,其行为切换为
输入
。作为旁注:您为什么试图调用
原始输入
的结果的
str
?你期望它做什么?(在从0.x到2.7的每一个具有
raw_input
的Python版本中,它都会返回一个
str
,因此对其调用
str
只会创建一个副本。)同时,如果您使用的是Python3.x,但使用的是为Python2.x编写的示例,您可能至少需要浏览一下,并在遇到类似问题时将其添加书签以进行搜索。例如,如果您搜索“<代码> RWYPixEng/<代码>”页,您会发现“PEP 3111:<代码> RWYIN()/代码>被重命名为<代码>输入()/代码>……“这是一个更简单的问题,然后我想…* FACEPALM *@ USER 8989968:好的:”如果您有帮助,请考虑接受这个答案。