Unicode within Maya

一世执手 提交于 2020-01-24 21:01:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!