Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the title is wrong标题乱码 #180

Closed
ianutin opened this issue Sep 5, 2023 · 3 comments
Closed

the title is wrong标题乱码 #180

ianutin opened this issue Sep 5, 2023 · 3 comments

Comments

@ianutin
Copy link

ianutin commented Sep 5, 2023

我使用以下代码生成一个头部导航:
from dominate.tags import *
import dominate
#' html_head
def setHtmlHeader(obj,html_title):
#' 添加 等头部信息
with obj.head:
meta(charset="UTF-8")
meta(name="viewport",content="width=device-width, initial-scale=1.0")
title(html_title)
link(rel="stylesheet",href="src/css/templatemo_main.css")
print("ok")
def setTitle(obj):
#' 渲染标题栏
title_1=img(cls="logo4",src="src/pics/button.png")
#title_1=h1("单细胞转录组测序分析报告")
title_2=a(href="#1")
title_3_1=div(style="float: left;",cls="aa")
title_2.add(title_1)
title_3_1.add(title_2)
title_3_2=h1("单细胞转录组测序分析报告")
title_4=div(cls="logo",style="width: 100%;")
title_4.add(title_3_1)
title_4.add(title_3_2)
title_5=div(cls="navbar-header",style="position:fixed;")
title_5.add(title_4)
title_6=div(cls="navbar navbar-inverse",role="navigation")
title_6.add(title_5)
obj.add(title_6)
def main():
html_title = "单细胞转录组测序分析报告"
html_root=dominate.document(lang="en",doctype="")
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())
但是得到的网页却是乱码!
image
不知道是哪里出了问题...

@ianutin
Copy link
Author

ianutin commented Sep 5, 2023

image

@ianutin
Copy link
Author

ianutin commented Sep 5, 2023

可是把相同的html内容复制到test2.html中,打开又不是乱码

@ianutin
Copy link
Author

ianutin commented Sep 5, 2023

解决了,纯纯是中文编码的问题

@ianutin ianutin closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant