【发布时间】:2021-11-27 21:26:49
【问题描述】:
当我运行 Python 脚本时,我的打印语句不会被写入输出/屏幕(请参阅下面的输出)。但是,在普通的 Windows 控制台/提示(和 macOS)中它可以工作:日志和打印消息都写入标准输出(混合)。
DEBUG:session_storage:session:getter: MainThread
DEBUG:urllib3.connectionpool:Resetting dropped connection: example.com
DEBUG:urllib3.connectionpool:https://example.com:443 "GET /QW/7720d5b252de HTTP/1.1" 200 1073
before api init
!!setting session
b
after api init
after request init
Process X-1 is running.
Got a valid value from queue
当我使用 CRTL-C 时,从 'before api init' 开始的文本会被打印出来(所以在程序执行之后)。
代码:
# SETUP LOGGING
logging.basicConfig(level=logging.DEBUG)
def main():
#another process is created via multiprocessing (process duplicated?)
...
logger = logging.getLogger(__name__)
if __name__ == '__main__':
main()
也许它与多处理部分有关?
【问题讨论】:
-
与git无关,所以去掉标签
标签: python windows printing output