こうじ | 2008年08月11日14時49分 | Python Pythonのテンプレートエンジンmakoを使ってみようと思ったが、日本語の扱いで苦労した。 まずは簡単なテンプレートの処理。 >>> from mako.template import Template >>> t = "Hello World!" >>> tpl = Template(t) >>> print tpl.render() Hello World! これは問題ない。 次に日本語を入れてみる。 >>> t = "こんにちは。" >>> tpl = Template(t) Traceback (most recent call last): 略 mako.exceptions.CompileException: Could not read template using encoding of 'ascii'.