我正在尝试将(在Windows中)python文件的输出重定向到使用boost :: program :: options创建的命令的stdin,如下所示:
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(CustomerOrder $order)
{
$this->authorize('view', $order);
return view('order.show', compact('order'));
}
test.py只打印文件的内容:
python test.py | command.exe -s
如果我只执行python文件它可以工作但是如果我尝试将它传递给另一个命令它失败并出现以下错误:
f = open('test.xml', 'r')
print f.read()
f.close()
如果我尝试执行此close failed in the file object destructor:
sys.excepthook is missin
lost sys.stderr
它可以正常工作,所以我猜管道有问题。
有没有人知道发生了什么?
答案 0 :(得分:0)
您收到此错误,因为 CMD 正在创建管道时,它正在关闭 STDERR 。并且python中文件obejct的方法close()
需要使用缺少的描述符。
可能的解决方案可能是这样的: https://superuser.com/questions/452763/how-to-pipleline-stderr-in-cmd-exe