Python基础——8错误、调试和测试
捕捉错误
try: print('try...') r = 10 / int('2') print('result:', r) except ValueError as e: print('ValueError:', e) except ZeroDivisionError as e: print('ZeroDivisionError:', e) else: print('no error!') finally: print('finally...') print('END')
调试
import logging
logging.baseConfig(level=logging.INFO)
…
logging.info(‘此处有错误’)
提示优先顺序为:DEBUG INFO WARNING ERROR四种
作者:八个增
-------------------------------------------
个性签名:苟日新 日日新 又日新!
如果这篇文章对你有些许帮助,记得在右下角点个“推荐”哦,俯首拜谢!