Maya 中的 Unicode

Unicode within Maya

在我的脚本中(用 Sublime Test 编写)我有一条评论:

# -*- coding: utf-8 -*-
import unicodedata

# Bööm! Bööm! Shake shake the room!
print u"Bööm! Bööm! Shake shake the room!"

在命令提示符下工作正常window。

但是,当将脚本拖放到 Maya 的脚本编辑器中时,同一行显示为:

# Bööm! Bööm! Shake shake the room!
print u"Bööm! Bööm! Shake shake the room!"

如何使评论按预期阅读?

肯定是Windows的问题。在 macOS El Capital 和 macOS Sierra 中运行良好。

import unicodedata
print u"Bööm! Bööm! Shake shake the room!"

#result: Bööm! Bööm! Shake shake the room!

虽然它是关于不同的主题,但看看这个有用的 SO post:Convert a Unicode string to a string in Python。这 post 可能会给你一些想法。

也许,你应该试试这个方法:

u = u"Bööm! Bööm! Shake shake the room!"
e = u.encode('utf8')
print e

#result: Bööm! Bööm! Shake shake the room!