AttributeError:partially initialized module ‘logging‘ has no attribute ‘basicConfig‘报错处理

使用python的logging库遇到的报错

  • 测试代码
  • 报错信息
  • 解决方法
    • 更改后结果

测试代码

文件名为:logging.py

import logging

logging.basicConfig()
logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')

报错信息

AttributeError: partially initialized module 'logging' has no attribute 'basicConfig' (most likely due to a circular import)

解决方法

logging.py文件替换为其他xx.py

更改后结果

WARNING:root:This is a warning message
ERROR:root:This is an error message
CRITICAL:root:This is a critical message

你可能感兴趣的:(python使用日常记录,python,logging)