python - 不能在django模板中使用unicode字符串

标签 python django python-2.7 django-templates

我在 django 模板中使用了“BỘ MÔN TOÁN”字符串,它引发了错误 “'utf8' 编解码器无法解码位置 569 中的字节 0xd4:无效的连续字节”。但是当我使用“BO MON TOAN”字符串时,它不会引发错误。所以,我在模板中使用了越南语,这是我的代码:

{% extends "site_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load url from future %}

{% block body_base %}
     <div class="subject-box-title">
         BỘ MÔN TOÁN
     </div>
{% endblock %}

这是我项目中的错误: enter image description here

我的项目中发生了什么。请帮助我,谢谢!

最佳答案

您可以在您的 HTML 标签中定义!

<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 

然后尝试 o/p 字符串。

关于python - 不能在django模板中使用unicode字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33866503/

相关文章:

python - PostgreSQL 类型错误 : not all arguments converted during string formatting

python - 树莓派 + 摄像头 + 步进电机 + Opencv

python - 如何计算列表中对的频率?

python - 将 Django 1.8 项目代码更新/升级到 Django 2.0

c++ - 在 Python 中使用 Boost 图形库

python - 检查字符串在 Python 中以什么数字结尾

Python CAN总线通知器

python - 如何从 Django 模型创建双长文本字段

python - 我需要做什么才能让 Fanjango 工作?

python - 在基于类的表单之间传递数据