这是在Windows 7(64位),Python 2.6和Win32 Extensions for Python上运行的.
我有一个简单的脚本,只打印"你好世界".我可以用它启动它python hello.py.在这种情况下,我可以将输出重定向到文件.但是如果我只是hello.py在命令行输入并重定向输出来运行它,我会得到一个例外.
C:> python hello.py
hello world
C:> python hello.py >output
C:> type output
hello world
C:> hello.py
hello world
C:> hello.py >output
close failed in file object destructor:
Error in sys.excepthook:
Original exception was:
Run Code Online (Sandbox Code Playgroud)
我想我升级到Windows 7后首先得到此错误.我记得它应该在XP中运行.我见过有人在谈论这个bug python-Bugs-1012692 | 无法将输入传递给python程序.但那是很久以前的事了.它没有提到任何解决方案.
有没有人经历过这个?有人可以帮忙吗?