python - raw_input ("") 已从 python 3.2 中删除

标签 python python-3.x python-2.7

我已经尝试了很多在 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/

相关文章:

python - 竞争性编程 Python : Repeated sum of digits Error

javascript - 面临有关填充 javascript 数组的问题

python - 使用列表推导式使函数更像 pythonic

为两个文件中存在的内容执行关键字匹配的 Python 程序

python - 按具有不同顺序的多个键对字典列表进行排序

python - 适用于 python 的 Google Api 客户端库不会在文件 : list method with query 中返回 nextPageToken

javascript - django 如何在模板中包含 javascript

python - 带有 if 表达式的 lambda 中的语法错误

python-3.x - BeautifulSoup get_text 返回 NoneType 对象

python-3.x - 用 Matplotlib 绘制 SVM?