日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

python日志模块为什么打印到界面_如何将外部模块的日志消息打印到主Python模块的终端窗口?...

發布時間:2025/4/16 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python日志模块为什么打印到界面_如何将外部模块的日志消息打印到主Python模块的终端窗口?... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我正在寫一個Python命令行程序。在

有一個主Python腳本文件,用作入口點。當用戶運行這個腳本時,它將執行一些外部Python腳本文件。外部Python腳本文件也可以執行其他外部Python腳本文件。外部文件的數量是可變的。在

Python腳本將使用以下方式執行外部Python腳本:p = subprocess.Popen(args)

or

p = subprocess.call(args)

當我在終端窗口中運行主Python腳本時,它將在運行時在屏幕上打印實時日志消息。現在,我希望從主Python腳本調用的所有外部Python腳本獲取所有日志消息,并將其打印到同一個終端窗口(我用來運行主腳本的終端窗口)。在

例如,以下是腳本執行的順序:

^{pr2}$

當我在終端窗口中運行主腳本時,是否可以像下面這樣在終端窗口上獲得實時日志消息?在[time-hh-mm-ss][log message from main script]Script is running..

[time-hh-mm-ss][log message from main script]Calling script layer-1-script-1..

[time-hh-mm-ss][log message from layer-1-script-1]Script is running..

[time-hh-mm-ss][log message from layer-1-script-1]Calling script layer-2-script-1..

[time-hh-mm-ss][log message from layer-2-script-1]Script is running..

[time-hh-mm-ss][log message from layer-2-script-1]Calling script layer-2-script-2..

[time-hh-mm-ss][log message from layer-2-script-2]Script is running..

[time-hh-mm-ss][log message from layer-2-script-2]Calling script layer-1-script-2..

[time-hh-mm-ss][log message from layer-1-script-2]Script is running..

[time-hh-mm-ss][log message from layer-1-script-2]Calling script layer-1-script-3..

[time-hh-mm-ss][log message from layer-2-script-3]Script is running..

[time-hh-mm-ss][log message from main script]Back to main script. Script is running..

有沒有可能我可以在終端窗口中得到一個real time log messages類似的內容?在

總結

以上是生活随笔為你收集整理的python日志模块为什么打印到界面_如何将外部模块的日志消息打印到主Python模块的终端窗口?...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。