![](/img/trans.png)
[英]Python: How can I output the datacompy.compare.report to a text or csv file? I can only see it in the terminal, need a file
[英]How can I see the entire output of a python file when run inside terminal?
終端在每次迭代時向上滾動時自動剪切輸出。
默認情況下,mac 終端的緩沖區行數是有限的。 說 1,000。
當您運行程序並且輸出超過 1000 行時,您的行將從內存中丟失。 這就像 FIFO 緩沖隊列。
基本上回答你的問題:
`Is there a way to store the output of the previously run command in a text file?` is no. Sorry.
您可以重新運行程序並通過將其重定向到另一個文件來保留輸出。 或者增加緩沖區中的行數(也許讓它不受限制)
您可以使用 less 來查看輸出:
your_command | less
你的Enter
鍵會讓你失望。
此外,按q
退出。
或者您可以將輸出重新路由到文件
在一個終端選項卡中運行程序並將輸出重定向到這樣的output.log
文件。
python program.py > output.log
在另一個選項卡中,您可以tailf
同一個日志文件並查看輸出。
tailf output.log
要查看完整的輸出,請在任何文本編輯器中打開日志文件。
可以考慮增加回滾緩沖區。
或者
如果您想查看數據並將其運行到文件中,請使用 tee,例如,
火花殼| 三通tmp.out
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.