gpt4 book ai didi

python - 使用 py2exe 创建 exe 后,raw_input 导致 EOFError

转载 作者:太空狗 更新时间:2023-10-30 00:08:30 25 4
gpt4 key购买 nike

在使用 py2exe raw_input() 从脚本创建 exe 后导致 EOFError。

我怎样才能避免这种情况?

 File "test.py", line 143, in main
raw_input("\nPress ENTER to continue ")
EOFError: EOF when reading a line

最佳答案

>>> help(raw_input)
Help on built-in function raw_input in module __builtin__:

raw_input(...)
raw_input([prompt]) -> string

Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading.

怎么了?你在键盘上输入什么?

编辑(在此处报告的评论):

我的猜测是您将 py2exe 与“windows”参数一起使用,这意味着没有打开控制台 - 没有控制台就没有供 raw_input 使用的标准输入。您可以改为在 setup.py 中使用“console”参数,您的 exe 将打开一个控制台窗口,允许 raw_input 工作

关于python - 使用 py2exe 创建 exe 后,raw_input 导致 EOFError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4280889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com