Python的HTML调试预打印

2024-09-30 10:27:05 发布

您现在位置:Python中文网/ 问答频道 /正文

在为PHP使用了优秀的Krumo包(也许最著名的是它在Drupal中的使用),我想知道Python是否有类似的东西。在

具体地说,我正在寻找一个能够完成以下工作的包:将任意(或几乎任意)Python变量转换为主题HTML/CSS。最好使用Javascript组件来折叠各种元素,但是如果需要的话,可以很容易地自己编写。在

有这样的模块吗?我更喜欢独立的,但如果这只是作为另一个web框架的一部分存在,它仍然是一个很好的起点。在


Tags: 模块框架web元素主题html组件javascript
2条回答

因为我找不到任何现有的库,所以我写了Pymo。它的功能与Krumo非常相似,将任何Python变量呈现为html,可以将其打印或保存到文件中,以便在web浏览器中查看,并使用javascript和CSS使其可读。在

请看一看,并提交错误报告或功能请求,如果它帮助你。在

也许cgitb就是你想要的:

The cgitb module provides a special exception handler for Python scripts. (Its name is a bit misleading. It was originally designed to display extensive traceback information in HTML for CGI scripts. It was later generalized to also display this information in plain text.) After this module is activated, if an uncaught exception occurs, a detailed, formatted report will be displayed. The report includes a traceback showing excerpts of the source code for each level, as well as the values of the arguments and local variables to currently running functions, to help you debug the problem. Optionally, you can save this information to a file instead of sending it to the browser.

相关问题 更多 >

    热门问题