python - “AttributeError:模块 'logging' 没有属性 'basicConfig'”
问题描述
我正在学习记录
In [11]: !cat program/codes/debug/logging.py
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime) -%(levelname)s - %(message)s")
logging.debug('Start of program')
def factorial(n):
logging.debug("Start of factorial(%s%%)" %(n))
total = 1
for i in range(n+1):
total *= i
logging.debug(f"i is {str(i)}, total is {str(total)}")
logging.debug("End of factorial(%s%%)" %(n))
return total
print(factorail(5))
logging.debug("End of program.")
它在运行时报告意外错误:
In [12]: !python program/codes/debug/logging.py
Traceback (most recent call last):
File "program/codes/debug/logging.py", line 1, in <module>
import logging
File "/Users/gaowei/Desktop/Pubrepo/program/codes/debug/logging.py", line 2, in <module>
logging.basicConfig(level=logging.DEBUG, format="%(asctime) -%(levelname)s - %(message)s")
AttributeError: module 'logging' has no attribute 'basicConfig'
"AttributeError: 模块 'logging' 没有属性 'basicConfig'",
但它是
In [13]: logging.basicConfig
Out[13]: <function logging.basicConfig(**kwargs)>
解决方案
推荐阅读
- python-3.x - Selenium 驱动程序在最大化和最小化时无法访问某些元素
- reactjs - 希望在构建时使用 webpack 动态排除代码块形成一个包
- c# - 如何使用 GZipStream.Read 方法读取数据
- css - 如何固定背景图像的位置?
- javascript - 如何在 Laravel 中使用 ajax 从模式中保存数据?
- tensorboard - 运行时更改 tensorboard 日志目录
- android - 为日期数组设置警报通知
- jsf - 选择下拉元素时,我想在 JSF 中启用 inputtext
- json - 读取 csv 文件会将其转换为 json,但它将其中的每一行作为空手道中的字符串
- html - 复选框标签中数字的大小