我正在练习一些代码,当我运行一段非常普通的代码时,我似乎无处不在地遇到了这个错误。我正在解决的问题需要输入,计算一些东西并给出输出。
我在一个在线 IDE(一些编码竞赛网站)上运行它,因为它不是很好(没有惊喜!)我决定在 Pycharm Community Edition 上运行它,然后复制粘贴到那里。它没有给我输出,而是显示了这个,
Traceback (most recent call last):
File "D:\Software\lib\io.py", line 52, in <module>
File "D:\practice\abc.py", line 1, in <module>
RuntimeError: input(): lost sys.stdin
Process finished with exit code -1073740791 (0xC0000409)
我试图运行的代码是这样的,
tc = int(input())
while tc > 0:
c = 0
a = int(input())
while a > 0:
print(a % 2)
if (a % 2 == 0):
a = a // 2
c += a
print(c, "is c")
tc -= 1
这可能有帮助,也可能没有帮助,但我不知道出了什么问题。
原文由 mach3 发布,翻译遵循 CC BY-SA 4.0 许可协议
该问题可能与您的代码编辑器/Python 窗口有关。例如,QGIS Python 控制台没有标准输入或标准输出,因此如果在那里运行代码,您会收到“RuntimeError: input(): lost sys.stdin”错误。
请参阅此帖子: https ://gis.stackexchange.com/questions/343250/error-when-using-input-pyqgis-runtimeerror-input-lost-sys-stdin-qgis-3