Debuging Django

栏目: Python · 发布时间: 6年前

内容简介:起初 hackernews 看到一个文章

起初 hackernews 看到一个文章 PySnooper: Never use print for debugging again ,觉得挺有意思的,结果把 hackernews 的讨论看了一下发现有意思东西更多一点,总结一下。

  1. [https://github.com/cool-RR/pysnooper][PySnooper]]: Never use print for debugging again,只需要给函数加一个装时期,就可以把函数执行的每一步的结果都打印出来。
  2. [https://django-extensions.readthedocs.io/en/latest/runserver_plus.html][django-extensions]] 的 runserver-plus 配合 Werkzeug 可以实现在遇到异常的时候,支持在 web 上面调试代码,打印异常的时候的上下文内容什么的。
  3. Python 自己的 breakpoint 函数,执行到的时候默认会进入 pdb.set_trace() 状态方便你进行上下文调试。
  4. [https://github.com/gruns/icecream][icecream]] 提供了一个方便的 ic 函数,可以无感的加入到你的代码里面,不影响你的代码的执行结果,但是会打印传给它的参数和执行结果。
  5. [https://github.com/robdmc/behold][Behold]]: A debugging tool for large Python projects,可以替代你写冗长的打印命令。不过感觉它自己的语法似乎也并不方便。。。
  6. VS Code 提供的 Logpoints 和 Visual Studio 提供的 Break When Value Changes
  7. [https://github.com/cknd/stackprinter][stackprinter]] 可以让你的堆栈打印更友好,打印堆栈的时候还可以输出上下文的取值。
  8. pdb, epdb,ipdb, 应该都是类似的东西,其中 pdb 是自带的。通过给代码增加 import ipdb ipdb.set_trace() 调试。
  9. [https://github.com/tylerwince/pydbg][pydbg]] 替代 print 的。

以上所述就是小编给大家介绍的《Debuging Django》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

SCWCD Exam Study Kit Second Edition

SCWCD Exam Study Kit Second Edition

Hanumant Deshmukh、Jignesh Malavia、Matthew Scarpino / Manning Publications / 2005-05-20 / USD 49.95

Aimed at helping Java developers, Servlet/JSP developers, and J2EE developers pass the Sun Certified Web Component Developer Exam (SCWCD 310-081), this study guide covers all aspects of the Servlet an......一起来看看 《SCWCD Exam Study Kit Second Edition》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具