Unicode within Maya

2019-08-04 17:38发布

In my script (written in Sublime Test) I've a comment that reads:

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

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

Which works fine in a command prompt window.

However, when dragging and dropping the script into Maya's script editor the same line reads:

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

How do I make the comment read as intended?

1条回答
Evening l夕情丶
2楼-- · 2019-08-04 18:09

It's definitely Windows' problem. In macOS El Capital and macOS Sierra it works fine.

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

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

Although it's about different topic, look at this useful SO post: Convert a Unicode string to a string in Python. This post might give you some ideas.

Maybe, you should try this method:

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!
查看更多
登录 后发表回答