python - 在执行我的 Python 代码时出现“EOFError: EOF when reading a line”。我该如何解决?
问题描述
我正在使用 Python3.8 制作一个程序,该程序在sys.stdin
. 这是代码:
import sys
try:
file = open(sys.argv[1], "r")
source = file.read()
file.close()
except:
source = sys.stdin.read()
input("\nPress enter to continue... \n")
如果用户没有提供参数,程序将继续使用标准输入。问题是:当我运行程序时,最后一行出现错误。这是输出:
$ apt-get install google* --print-uris | ./scrFiles/pythonFiles/code.py
Press enter to continue...
Traceback (most recent call last):
File "./scrFiles/pythonFiles/code.py", line 12, in <module>
input("\nPress enter to continue... \n")
EOFError: EOF when reading a line
我的代码有什么问题?:/
解决方案
推荐阅读
- visual-studio - SSRS 报告 - 报告服务 RDLC
- asp.net-core - 在 ASP.NET Core 中的电子邮件确认令牌过期后删除用户
- javascript - react-widget 组件未正确呈现
- python - 无法在 Pycharm 窗口中运行 .Robot 文件
- python - 在 Azure VMSS 中获取实例的公共 IP?
- python - 处理需要格式化不带小数位的 float nan 列
- java - 小字符串的 TransactionTooLargeException 错误
- javascript - Eslint 无法读取配置文件
- meteor - Meteor Autoform - 如何显示特定的用户数据?
- arrays - 致命错误:在展开可选值时意外发现 nil