Python gettext:将 Unicode 文字转换为文本
我在 Windows 中工作。 Python 2.7.2 我有一个模块,我必须在其中使用 gettext 翻译一些消息。 所以我创建了 UTF-8 no BOM *.po 文件,用它制作 *.mo 并使用如下代码:
t = gettext.translation('index','./locale', languages=['ru'])
_= t.ugettext
t.install()
结果我有这样的东西:
(u'\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430')
如何将其转换为常见的 UTF-8 文本?
I work in Windows. Python 2.7.2
I have a module in which i have to translate a few messages with gettext.
So i create UTF-8 no BOM *.po file, make *.mo out of it and use code like this:
t = gettext.translation('index','./locale', languages=['ru'])
_= t.ugettext
t.install()
As a result i have something like this:
(u'\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430')
How to covert it into common UTF-8 text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是错误的问题。 :) 它已经是 UTF-8 文本...您想要了解的是如何将其显示为字母字符。对于任何使用字符串作为视觉输出的东西来说,这应该是自动的。最简单的情况是
print
函数(或语句)。This is the wrong question. :) It is already UTF-8 text... What you are trying to understand is how to display it as alphabetical characters. This should be automatic in anything that uses strings as visual output. The easiest case, the
print
function (or statement).