raw_input.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:blender 作者: gastrodia 项目源码 文件源码
def raw_input(prompt=""):
    """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."""

    sys.stderr.flush()

    tty = STDIN.is_a_TTY() and STDOUT.is_a_TTY()

    if RETURN_UNICODE:
        if tty:
            line_bytes = readline(prompt)
            line = stdin_decode(line_bytes)
        else:
            line = stdio_readline(prompt)

    else:
        if tty:
            line = readline(prompt)
        else:
            line_unicode = stdio_readline(prompt)
            line = stdin_encode(line_unicode)

    if line:
        return line[:-1] # strip strailing "\n"
    else:
        raise EOFError
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号