Python 为什么在输入消息之后显示日志消息?

Python 为什么在输入消息之后显示日志消息?,python,python-3.x,Python,Python 3.x,输入函数似乎在日志消息之前显示消息。为什么会发生这种情况 import configparser from pathlib import Path import logging log = logging.getLogger('test') log.debug('Current directory: {}'.format(Path().absolute()) ) filename = input('load ini from > ') config = configparser.Conf

输入函数似乎在日志消息之前显示消息。为什么会发生这种情况

import configparser
from pathlib import Path
import logging

log = logging.getLogger('test')
log.debug('Current directory: {}'.format(Path().absolute()) )
filename = input('load ini from > ')
config = configparser.ConfigParser()
config.read(filename)

谢谢。

试试:
handler=logging.StreamHandler(sys.stdout);log.addHandler(handler)
我无法重现该问题。对于log.debug,不会打印任何内容(默认级别为警告)。使用log.warning时,日志消息出现在输入之前。