Maya中的Unicode [英] Unicode within Maya

查看:161
本文介绍了Maya中的Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的脚本(用Sublime测试编写)中,有一条注释内容为:

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.

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

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?

推荐答案

这肯定是Windows的问题.在macOS El Capital和macOS Sierra中,它可以正常工作.

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!

尽管它涉及的是不同的主题,但请查看此有用的SO文章:

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!

这篇关于Maya中的Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆