问题
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:
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!
来源:https://stackoverflow.com/questions/48719312/unicode-within-maya