[英]output result of python program in both terminal and file
我試過了,但命令是一個具有輸入“ raw_input()”的python程序
someCommand | tee someFile
當程序要求輸入時,輸出停止
有幾種解決方法。 raw_input()
讀取標准輸入 ( stdin
),可以從管道,文件甚至其他進程重定向:
使用管道:
echo "some text" | someCommand | tee someFile
從文件中:
someCommand < inputfile | tee someFile
從另一個程序:
someCommand < <(anotherprog) | tee someFile
在每種情況下,換行符都應終止數據。
或者,可以更改python程序,以便將其寫入輸出文件以及控制台,但是我猜這不是一個選擇。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.