Ich habe die folgenden DateienUnicodeEncodeError in Mako Vorlage
dummy.py
#!c:/Python27/python.exe -u
from mako import exceptions
from mako.template import Template
print "Content-type: text/html"
print
#VARIABLE = "WE"
VARIABLE = "我们"
template = Template(filename='../template/dummy.html', output_encoding='utf8')
try:
print template.render(VARIABLE=VARIABLE)
except:
print exceptions.html_error_template().render()
dummy.html (in UTF-8-Format gespeichert)
hello world
哈罗世界
${VARIABLE}
Ich hatte auf die Anweisung vonverwiesen
Allerdings bekomme ich immer noch Fehler
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
Alles, was ich verpasst habe?
Entschuldigung. Ich habe meine Problemaussage nicht genau gemacht. Ich formuliere es, das Problem liegt in der Analyse der Variablen. –
@Yan Check CHEOK: Das ist, weil Sie nicht Unicode für Ihre Variablen verwenden. Ändere '" 我们 "' zu 'u" 我们 "' und du bist im Geschäft. –