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

在python中读取stdin时,管道文件描述符错误

  •  2
  • sharkin  · 技术社区  · 17 年前

    this

    scriptA.py | scriptB.py
    

    sys.stdout.write( "hello" )
    

    print sys.stdin.read()
    

    c:\> scriptA.py | scriptB.py
    close failed: [Errno 22] Invalid argument
    Traceback (most recent call last):
      File "c:\scriptB.py", line 20, in <module>
        print sys.stdin.read()
    IOError: [Errno 9] Bad file descriptor
    

    “关闭失败”消息似乎来自scriptA.py的执行。

    发生了什么?

    1 回复  |  直到 9 年前