""" 调试 """
__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 断电单步调试

 

相关文章:

  • 2021-12-22
  • 2021-09-12
  • 2021-10-06
  • 2022-01-23
  • 2021-08-20
  • 2021-09-18
  • 2021-08-27
猜你喜欢
  • 2021-05-24
  • 2021-09-18
  • 2021-05-29
  • 2021-11-26
  • 2021-07-08
  • 2021-08-21
  • 2021-07-18
相关资源
相似解决方案