如果您能帮助我解决一个看似微不足道的问题,我将不胜感激。最近我开始学习 Python,以便在 Google App Engine 环境中工作。不用说,我是从最简单的 Hello World 应用开始的。
它的英文版很好用
但是,当我尝试使用我的母语来处理符号时,问题就来了。基本上当在本地机器上运行时它不能正确显示字母。
这是导致我出现问题的一段代码
# -*- coding: utf-8 -*-
import datetime
print 'Content-Type: text/html'
print ''
print '<html>'
print '<head>'
print '<title>Witaj świecie</title>'
print '</head>'
print '<body>'
print '<h1>Witaj świecie</h1>'
print ''
print 'Data logowania to: %s' % (datetime.datetime.now())
print '</body>'
print '</html>'
当然我所有的文件都保存为utf-8格式。谁能告诉我如何在这里正确显示 utf-8 字符?
最佳答案
print '<html>'
print '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
print '<head>'
关于python - Python 的 Google App Engine utf-8 编码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7096481/