首页 / HTML / python生成html报告
python生成html报告
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python生成html报告,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1827字,纯文字阅读大概需要3分钟。
内容图文
class Template_mixin(object):
"""html报告"""
HTML_TMPL = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>自动化测试报告</title>
<link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<h1 style="font-family: Microsoft YaHei">自动化测试报告</h1>
<p class=‘attribute‘><strong>测试结果 : </strong> %(value)s</p>
<style type="text/css" media="screen">
body { font-family: Microsoft YaHei,Tahoma,arial,helvetica,sans-serif;padding: 20px;}
</style>
</head>
<body>
<table id=‘result_table‘ class="table table-condensed table-bordered table-hover">
<colgroup>
<col align=‘left‘ />
<col align=‘right‘ />
<col align=‘right‘ />
<col align=‘right‘ />
</colgroup>
<tr id=‘header_row‘ class="text-center success" style="font-weight: bold;font-size: 14px;">
<th>步数</th>
<th>时间</th>
<th>用例执行结果</th>
<th>原因</th>
</tr>
%(table_tr)s
</table>
</body>
</html>"""
TABLE_TMPL = """
<tr class=‘failClass warning‘>
<td>%(step)s</td>
<td>%(runtime)s</td>
<td>%(runresult)s</td>
<td>%(reason)s</td>
</tr>"""
if __name__ == ‘__main__‘:
table_tr0 = ‘‘
numfail = 1
numsucc = 9
html = Template_mixin()
table_td = html.TABLE_TMPL % dict(
step=‘1‘,
runtime=datetime.datetime.now(),
runresult=‘Fail‘,
reason=‘失败或成功原因‘,
)
table_tr0 += table_td
total_str = ‘共 %s,通过 %s,失败 %s‘ % (numfail + numsucc, numsucc, numfail)
output = html.HTML_TMPL % dict(
value = total_str,
table_tr = table_tr0,
)
#生成html报告
with open("Decision_KKD.html",‘wb‘) as f:
f.write(output.encode(‘utf-8‘))
原文:http://www.cnblogs.com/sammy1989/p/7598141.html
内容总结
以上是互联网集市为您收集整理的python生成html报告全部内容,希望文章能够帮你解决python生成html报告所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。