标签:asi icc %s bug span ble 参数 ctime 现在
import logging logging.basicConfig(level=logging.DEBUG, format=‘ %(asctime)s - %(levelname)s: %(message)s‘) #format显示格式可按自己喜好调整 #logging.disable(logging.CRITICAL) #调试日志是否显示开关 logging.debug(‘程序现在开始!‘) #调试日志开始标记 def factorial(n): logging.debug(‘开始执行:factorial(%s)‘ % (n)) #日志标记把正在执行的参数 total = 1 for i in range(n + 1): total *= i logging.debug(‘此处【i】值是:‘ + str(i) + ‘,【total】值是:‘ + str(total))#要调试处用logging.debug代替print logging.debug(‘结束执行:factorial(%s)‘ % (n)) #日志标记把正在执行的参数 return total print(factorial(5)) logging.debug(‘程序已经结束!‘) #调试日志结束标记
调试过程将显示:
2019-03-15 14:17:01,538 - DEBUG: 程序现在开始!
2019-03-15 14:17:01,548 - DEBUG: 开始执行:factorial(5)
2019-03-15 14:17:01,551 - DEBUG: 此处【i】值是:0,【total】值是:0
2019-03-15 14:17:01,554 - DEBUG: 此处【i】值是:1,【total】值是:0
2019-03-15 14:17:01,557 - DEBUG: 此处【i】值是:2,【total】值是:0
2019-03-15 14:17:01,560 - DEBUG: 此处【i】值是:3,【total】值是:0
2019-03-15 14:17:01,586 - DEBUG: 此处【i】值是:4,【total】值是:0
2019-03-15 14:17:01,606 - DEBUG: 此处【i】值是:5,【total】值是:0
2019-03-15 14:17:01,628 - DEBUG: 结束执行:factorial(5)
0
2019-03-15 14:17:01,672 - DEBUG: 程序已经结束!
标签:asi icc %s bug span ble 参数 ctime 现在
原文地址:https://www.cnblogs.com/chenxi188/p/10536747.html