生成HTML页面的Python模块 PyH
jopen
13年前
<p><img title="生成HTML页面的Python模块 PyH" border="0" alt="生成HTML页面的Python模块 PyH" src="https://simg.open-open.com/show/205f816be34a97d27aa614c79f02a55d.png" width="55" height="55" /><br /> PyH 是一个用来生成HTML页面的Python模块,使用面向对象的方式,HTML的标签都会对应一个Python的对象,输出的HTML文档排版良好,易于阅读。</p> <p>示例代码:</p> <p></p> <pre class="brush:python; toolbar: true; auto-links: false;">from pyh import * page = PyH('My wonderful PyH page') page.addCSS('myStylesheet1.css', 'myStylesheet2.css') page.addJS('myJavascript1.js', 'myJavascript2.js') page << h1(cl='center', 'My big title') page << div(cl='myCSSclass1 myCSSclass2', id='myDiv1') << p(id='myP1', 'I love PyH!') mydiv2 = page << div(id='myDiv2') mydiv2 << h2('A smaller title') + p('Followed by a paragraph.') page << div(id='myDiv3') page.myDiv3.attributes['cl'] = 'myCSSclass3' page.myDiv3 << p('Another paragraph') page.printOut()</pre> <p></p> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324432362608" target="_blank">http://www.open-open.com/lib/view/home/1324432362608</a></p>