python控制台美化输出_一个Python模块,把你的控制台输出为HTML

prynt is a Python module to turn your console outputs into HTML or tex file. Just import the prynt module, and your output will be automagically turned into an HTML/tex file.

Getting Started

Prynt is a easy way to generate quite nice reports. It is nowhere near a full CMS webapp: that's even not the purpose.

The goal for prynt, is to provide an easy (really easy) way to generate nice ( quite nice) reports.

Let's see an "Hello World":

from prynt import *pryntonexit()print "*Hello* **World**"

will lead to

Hello World

that's it.

How does it work

The principle is easy :

when importing prynt module, the standard stdout is replace by the prynt one. This prynt stdout, just forward calls to the standard (in fact the one that waas previously in sys.stdout), and store the outputs into a buffer.

the "pryntonexit()" instruction register a simple hook on python exit, that just call the "prynt()" method.

The prynt method, flushes the buffer, and send the buffer to rst2html, save the result (html code) into a html file.

That's the main idea of prynt.

ReST Integration

For example, execute this code :

```

from prynt import *

pryntonexit()

import prynt.rest as rst

print rst.title(Hello Python)

print rst.image("http://www.python.org/images/python

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值