我已经尝试了很多在 python 控制台上运行 raw_input("")
,但是这给出了一个错误。此外,我还观看了一些可能是在旧 python 上制作的视频。所以 input("")
是唯一的方法,为什么 raw_input("")
在新版本中被丢弃,有什么原因吗?
最佳答案
raw_input()
在 Python v3.x 中被重命名为 input()
旧的 input()
不见了,但你可以用 eval(input())
What's new in Python 3会提到这个(以及更多):
PEP 3111: raw_input() was renamed to input(). That is, the new input() function reads a line from sys.stdin and returns it with the trailing newline stripped. It raises EOFError if the input is terminated prematurely. To get the old behavior of input(), use eval(input()).
关于python - raw_input ("") 已从 python 3.2 中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10885537/