python脚本生成html
短信预约 -IT技能 免费直播动态提醒
#-*- coding: utf-8 -*-
from pyh import *
CONST_LIST = [ ['1','AAA','100','100','100','300'],
['2','BBB','99','99','99','297'],
['3','CCC','98','98','98','294']]
class ToHTML:
def __init__(self,project = 'TEST', version = 'v1.0'):
self.page = PyH('%s 测试报告' % project)
self.project = project
def tablecss(self, table = None, width = '600'):
table.attributes['cellSpacing'] = 1
table.attributes['cellPadding'] = 1
table.attributes['border'] = 1
table.attributes['borderColor'] = 'green'
table.attributes['width'] = 'width'
def tr_title_css(self, tr = None, color = '#B0C4DE'):
tr.attributes['bgcolor'] = color
def gentitle(self, name):
self.page << div(b('%s测试报告' % name), id = 'mydiv')
self.tableGroup = self.page << table()
self.tablecss(self.tableGroup,width = '600')
title_tr_group = self.tableGroup << tr()
self.tr_title_css(title_tr_group)
title_tr_group.attributes['align'] = 'center'
title_tr_group << td('<b>名次</b>',style = 'width:100')
title_tr_group << td('<b>姓名</b>',style = 'width:100')
title_tr_group << td('<b>语文</b>',style = 'width:100')
title_tr_group << td('<b>数学</b>',style = 'width:100')
title_tr_group << td('<b>英语</b>',style = 'width:100')
title_tr_group << td('<b>总分</b>',style = 'width:100')
self.page << br()
def setcontent(self,unit):
value_tr_unit = self.tableGroup << tr()
for unitOne in unit:
value_tr_unit << td('%s' % unitOne)
def genreport(self, filename = 'report.html'):
self.page << '结束:'
try:
self.page << 'finished'
except:
self.page << 'unfinished'
self.page << br()
self.page.printOut(filename)
# self test
if __name__ == '__main__':
rp = ToHTML('TEST')
rp.gentitle('FORM')
for unit in CONST_LIST:
rp.setcontent(unit)
from pyh import *
CONST_LIST = [ ['1','AAA','100','100','100','300'],
['2','BBB','99','99','99','297'],
['3','CCC','98','98','98','294']]
class ToHTML:
def __init__(self,project = 'TEST', version = 'v1.0'):
self.page = PyH('%s 测试报告' % project)
self.project = project
def tablecss(self, table = None, width = '600'):
table.attributes['cellSpacing'] = 1
table.attributes['cellPadding'] = 1
table.attributes['border'] = 1
table.attributes['borderColor'] = 'green'
table.attributes['width'] = 'width'
def tr_title_css(self, tr = None, color = '#B0C4DE'):
tr.attributes['bgcolor'] = color
def gentitle(self, name):
self.page << div(b('%s测试报告' % name), id = 'mydiv')
self.tableGroup = self.page << table()
self.tablecss(self.tableGroup,width = '600')
title_tr_group = self.tableGroup << tr()
self.tr_title_css(title_tr_group)
title_tr_group.attributes['align'] = 'center'
title_tr_group << td('<b>名次</b>',style = 'width:100')
title_tr_group << td('<b>姓名</b>',style = 'width:100')
title_tr_group << td('<b>语文</b>',style = 'width:100')
title_tr_group << td('<b>数学</b>',style = 'width:100')
title_tr_group << td('<b>英语</b>',style = 'width:100')
title_tr_group << td('<b>总分</b>',style = 'width:100')
self.page << br()
def setcontent(self,unit):
value_tr_unit = self.tableGroup << tr()
for unitOne in unit:
value_tr_unit << td('%s' % unitOne)
def genreport(self, filename = 'report.html'):
self.page << '结束:'
try:
self.page << 'finished'
except:
self.page << 'unfinished'
self.page << br()
self.page.printOut(filename)
# self test
if __name__ == '__main__':
rp = ToHTML('TEST')
rp.gentitle('FORM')
for unit in CONST_LIST:
rp.setcontent(unit)
rp.genreport('form.html')
####################
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341