import os _HTML_BASE="""
{name}:{value}
""" 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)