美文网首页
python debug 利器 better_exception

python debug 利器 better_exception

作者: ldh123 | 来源:发表于2017-12-05 17:17 被阅读0次

经常出现异常的时候很烦躁的是不知道到底是什么导致了异常,只能加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

相关文章

网友评论

      本文标题:python debug 利器 better_exception

      本文链接:https://www.haomeiwen.com/subject/sxbcixtx.html