66 lines
1.3 KiB
Python
66 lines
1.3 KiB
Python
|
|
import os
|
|
|
|
|
|
|
|
|
|
_HTML_BASE="""
|
|
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width">
|
|
<title>检测数据分析</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="container" style="width:1300px">
|
|
<table width="1300px">
|
|
{items}
|
|
</table>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|
|
"""
|
|
|
|
_HTML_ITEM="""
|
|
<tr>
|
|
<td colspan="2" style="background-color:#FFA500;">
|
|
<img src="pic/{pic_name}" alt="{pic_name}"></img>
|
|
</td>
|
|
<td colspan="2" style="background-color:#FFA500;" width="500px">
|
|
{params}
|
|
</td>
|
|
</tr>
|
|
"""
|
|
|
|
_HTML_PARAM="""
|
|
<p>{name}:{value}</p>
|
|
"""
|
|
|
|
|
|
|
|
|
|
def html_build(path:str,pic_names:list,params:list):
|
|
h_item=""
|
|
index=0
|
|
for pic,par in zip(pic_names,params):
|
|
h_param=""
|
|
h_param+=_HTML_PARAM.format(name="任务序号",value=index)
|
|
for i in par:
|
|
h_param+=_HTML_PARAM.format(name=i[0],value=i[1])
|
|
pic_name='.'.join([str(index),pic,'png'])
|
|
h_item+=_HTML_ITEM.format(pic_name=pic_name,params=h_param)
|
|
index+=1
|
|
html=_HTML_BASE.format(items=h_item)
|
|
if not os.path.exists(path):
|
|
os.makedirs(path)
|
|
save_name=os.path.join(path,"home.html")
|
|
with open(save_name,"w+",encoding="utf-8") as f:
|
|
f.write(html)
|
|
|
|
|
|
# if __name__=="__main__":
|
|
# html_add_item("30.充能时间.png",None) |