重复的这个问题.投票关闭.
Duplicate of this question. Vote to close.
在Windows命令行中考虑这一点.
Consider this at the windows commandline.
scriptA.py | scriptB.py在scriptA.py中:
In scriptA.py:
sys.stdout.write( "hello" )在scriptB.py中:
In scriptB.py:
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.
The "close failed" message seems to come from execution of scriptA.py.
是否使用sys.stdin.read(),sys.stdin.read(1),sys.stdin.readlines()等都没关系.
It doesn't matter if I use sys.stdin.read(), sys.stdin.read(1), sys.stdin.readlines() etc etc.
怎么了?
重复的这个问题.投票关闭.
Duplicate of this question. Vote to close.
推荐答案从文件关联开始时,似乎stdin/stdout重定向不起作用. 这不是特定于python的问题,而是由win32 cmd.exe引起的问题.
It seems that stdin/stdout redirect does not work when starting from a file association. This is not specific to python, but a problem caused by win32 cmd.exe.
请参阅: mail.python. org/pipermail/python-bugs-list/2004-August/024920.html
更多推荐
在python中从stdin读取时出现错误的管道文件描述符
发布评论