Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API. It allows you to write HTML pages in pure Python very concisely, which eliminate the need to learn another template language, and to take advantage of the more powerful features of Python.
我使用以下代码生成一个头部导航: from dominate.tags import * import dominate
' html_head
def setHtmlHeader(obj,html_title):
' 添加 等头部信息
def setTitle(obj):
' 渲染标题栏
def main(): html_title = "单细胞转录组测序分析报告" html_root=dominate.document(lang="en",doctype="<!DOCTYPE html>") setHtmlHeader(html_root,html_title) setTitle(html_root) with open('E:/2023洛兮医疗/01.资料/05.html_test/03.reports_out/03.reports_out/test.html','w') as f: f.write(html_root.render()) 但是得到的网页却是乱码! 不知道是哪里出了问题...