logging
print
import logging logger = logging.getLogger(__name__) # 在任何 Python 文件的开头导入 logging 模块,并定义 logger 对象 logger.info('This is an info message') # 使用 logger.info 记录信息级别日志 logger.warning('This is a warning message') logger.error('This is an error message')