python3(三十三)debug

""" 调试 """
__author__on__ = 'shaozhiqi  2019/9/23'

# 调试程序
# 1. print打印,没问题了上线还得删掉
# 2. 断言、assert
# n不等于0则继续执行,否则走断言的处理,Python解释器时可以用-O参数来关闭assert
# def foo(s):
#     n = int(s)
#     assert n != 0, 'n is zero!'
#     return 10 / n
#
#
# def main():
#     foo('0')

# 3. loging日志之,可以打印到日志文件
import logging

logging.basicConfig(level=logging.INFO)
s = '0'
n = int(s)
logging.info('n = %d' % n)  # INFO:root:n = 0
print(10 / n)

# 4. 利用idea的debug 断电单步调试
原文地址:https://www.cnblogs.com/shaozhiqi/p/11574053.html