python - raw_input() 出了什么问题(EOFError : EOF when reading a line)

标签 python

我使用的是python 2.7.6,调用raw_input()时出现异常:

flight_name = raw_input('\nEnter the name of Flight: ')

找到解决办法了,为什么会出现这样的异常?是包吗?

try:
      flight_name = raw_input('\nEnter the name of Flight: ')
except (EOFError):
      break

最佳答案

你可以使用:

sys.stdin = open('/dev/tty')
answer = raw_input('Commit anyway? [N/y] ')

来源:https://stackoverflow.com/a/7437724/1465640

关于python - raw_input() 出了什么问题(EOFError : EOF when reading a line),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21385011/

相关文章:

python - sklearn 分解顶级项

python - boolean 上下文中的 bool 和 int 类型

python - 通过名称获取对嵌入式 python 函数的 C 引用?

python - 绘制具有 7 个特征的 Scikit Logistic 回归的决策边界

python - django-cms makemigrations错误: No module named 'packaging'

python - Pandas 和 Plotly : how to access data columns in the hover text that are not used to plot the point?

Python kafka消费者不会消费来自生产者的消息

python - 将日期时间对象与 8601 字符串进行比较会给出错误的结果,为什么允许这样做?

python - 如何减少 python-docx 中段落之间的间距

python - 安装 X 协议(protocol)以使用 mysql shell - Mac