我有一组 UTF-8 字符,我想插入到PyX
生成的 pdf 文件中。我已包含# -*- coding: utf-8 -*-
在文件顶部。代码有点类似于以下内容:
# -*- coding: utf-8 -*-
c = canvas.canvas()
txt = "u'aあä'"
c.text(2, 2, "ID: %s"%txt)
c.writeEPSfile("filename.eps")
但我仍然无法理解这一点。
错误:
'ascii' codec can't encode character u'\xae' in position 47: ordinal not in range(128)