[英]how to encode string to utf8 inside html
I'm trying to use awdeoroi mailmerge.我正在尝试使用 awdeoroi 邮件合并。 In the html template i have french encoded characters in paragraph tags.
在 html 模板中,我在段落标签中有法语编码字符。 When i execute the mailing i have encoding errors:
当我执行邮件时,我有编码错误:
UnicodeDecodeError : 'utf-8' codec can't decode byte 0xf4 in position 81: invalid continuation byte
How to encode those paragraph so that they are well treated in python?如何对这些段落进行编码,以便在 python 中得到很好的处理?
TO: {{email}}
SUBJECT: Testing mailmerge
FROM: My Self <myself@mydomain.com>
Content-Type: text/html
<html>
<body>
<p>Hi, {{name}},</p>
<p>Your number is {{number}}.</p>
<p>Sent by <a href="https://github.com/awdeorio/mailmerge">Here is the paragraph. Ce texte est en francais. <b>Accentué<b>. L'ideal</a></p>
</body>
</html>
Hex f4
is latin1 for ô
.十六进制
f4
是ô
的 latin1 。 If this was typed into Python, you needed this at the start of the source file:如果这是在 Python 中输入的,则您需要在源文件的开头这样做:
# -*- coding: utf-8 -*-
If the data is coming from a database, please provide some more details.如果数据来自数据库,请提供更多详细信息。
If the text is coming from somewhere else, please provide some more details.如果文本来自其他地方,请提供更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.