python debug 利器 better_exceptions

经常出现异常的时候很烦躁的是不知道到底是什么导致了异常,只能加log或者print重现。最近发现一个包better_exceptions,只要import了这个包,就可以直接在exception时候把值都打印出来,打印的还挺漂亮,mark一下

安装

pip install better_exceptions

使用

import better_exceptions

也可以用 python -m better_exceptions 在命令行里用

ly@ly-VirtualBox:/tmp$ python -m better_exceptions 
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
(BetterExceptionsConsole)
>>> a=[]
>>> a[1]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
    a[1]
    └ []
IndexError: list index out of range
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。