Python:traceback模块的format_tb()函数(例外的堆栈追踪5)
2018-11-04 11:59
495 查看
[code]""" traceback.format_tb(tb,limit=None) 返回堆栈跟踪条目的列表 tb:要跟踪的traceback对象 limit: 这个是限制stack trace层级的,如果不设或者为None,就会打印所有层级的stack trace """ import time,sys def m(): return 1 / 0 def n(): m() def p(): n() if __name__ == '__main__': try: p() except: import traceback ttype,tvalue,ttraceback = sys.exc_info() for i in traceback.format_tb(ttraceback): print(i) time.sleep(1) print("继续执行")
阅读更多
相关文章推荐
- Python之异常追踪模块:traceback
- python常用函数库及模块巧妙用法汇总
- Python生成随机数与random模块中最常用的几个函数
- python中collections 模块里的defaultdict()函数
- 基础入门_Python-模块和包.为wsgiref实现的WSGI服务器编写处理函数?
- Python中的类,模块,函数
- python os模块常用函数
- Python format 格式化函数
- 【转】Python random模块常用函数
- Python 引用多个模块,调用模块中的函数时...要注意的地方
- Python中的traceback模块
- python,格式化字符串函数.format()的用法
- python里使用cv2.goodFeaturesToTrack()函数追踪图像里的关键点
- python调用模块&函数
- Python里的OS模块常用函数说明
- [Python]re模块的核心函数和方法
- Python str.format()函数
- Python笔记day45(MySQL)|视图、触发器、存储过程、函数、事务、pymsql模块
- 使用pycallgraph,追踪Python函数内部调用
- Python中的traceback模块