python日志模块使用
作者:互联网
"""
日志模块的使用
"""
import logging
# 加上filename,日志会输出到文件里
logging.basicConfig(filename='myProgramLog.txt', level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
# 禁用INFO及更低级别的日志
# logging.disable(level=logging.INFO)
def factorial(n):
logging.debug('Start of factorial(%s)' % n)
total = 1
for i in range(1, n + 1):
total *= i
logging.debug('i is ' + str(i) + ', total is ' + str(total))
logging.debug('End of factorial(%s)' % n)
return total
print(factorial(5))
logging.debug('End of program')
标签:logging,python,factorial,模块,debug,End,日志,total 来源: https://www.cnblogs.com/fly-book/p/15912089.html