代码之家  ›  专栏  ›  技术社区  ›  volting

用py2exe创建exe后导致eoferor的原始输入

  •  6
  • volting  · 技术社区  · 14 年前

    在使用 py2exe raw_input() 正在导致一个eoferor。

    我怎样才能避免这个?

     File "test.py", line 143, in main
        raw_input("\nPress ENTER to continue ")
    EOFError: EOF when reading a line
    
    1 回复  |  直到 14 年前
        1
  •  4
  •   Ant    11 年前
    >>> 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”参数,这意味着没有打开控制台-没有控制台,就没有可供原始输入使用的stdin。相反,您可以在setup.py中使用“console”参数,您的exe将打开一个控制台窗口,允许原始输入工作