나는이 dummy.htmlUnicodeEncodeError 마코에서 템플릿
#!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()
(UTF-8 형식으로 저장)
hello world
哈罗世界
${VARIABLE}
dummy.py 다음 파일
나는의 지시를 심리했다.
그러나, 나는 아직도 내가 놓쳤다했다
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
아무것도 오류 얻을?
죄송합니다. 나는 나의 문제 진술을 정확하게하지 않았다. 다시 말하면 문제는 변수를 구문 분석하는 중입니다. –
@ Yan Check CHEOK : 변수에 유니 코드를 사용하지 않기 때문입니다. ''我们 ''를'u ''我们 ''로 변경하면 사업을 시작하게됩니다. –