“ AttributeError:模块'logging'没有属性'basicConfig'”

时间:2018-12-18 01:06:55

标签: python

我正在学习日志记录

:ss

运行时报告意外错误:

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.")

“ AttributeError:模块'logging'没有属性'basicConfig'”,

但是是

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'

0 个答案:

没有答案