如何在html中将字符串编码为utf8

2024-05-02 06:33:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用awdeoroi邮件合并。在html模板中,我在段落标记中使用了法语编码字符。 当我执行邮件时,我有编码错误:

UnicodeDecodeError : 'utf-8' codec can't decode byte 0xf4 in position 81: invalid continuation byte

如何对这些段落进行编码,以便在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>

Tags: com模板number编码ishtml错误邮件
1条回答
网友
1楼 · 发布于 2024-05-02 06:33:11

Hexf4ô的拉丁文1。如果这是在Python中键入的,则在源文件的开头需要:

# -*- coding: utf-8 -*-

如果数据来自数据库,请提供更多详细信息

如果文本来自其他地方,请提供更多详细信息

相关问题 更多 >