【问题标题】:What is the difference between the Python type method and the type function on a Maya Transform Node?Python 类型方法和 Maya 变换节点上的类型函数有什么区别?
【发布时间】:2016-03-09 03:35:06
【问题描述】:

题目中的问题

示例代码:

>>> j.type()
u'joint'
>>> type(j)
<class 'pymel.core.nodetypes.Joint'>

【问题讨论】:

    标签: python maya pymel


    【解决方案1】:

    看看这个简单的例子。您正在尝试比较两个不同的东西 - Joint 类方法 type 和 python 内置函数 type - 它们都有相同的名称:

    class Joint():
        def type(self):
            return u'joint'
    
    >>> j = Joint()
    >>> j.type()
    'joint'
    >>> type(j)
    <class '__main__.Joint'>
    

    【讨论】:

    • @shfury u 表示 unicode。你用的是什么系统和python版本?
    • @shfury 起初我实际上尝试在 python2 中运行这个示例,因为你存在于这一行 - return u'joint'。但是当我意识到你在 python3 上(通过内置的type 返回值)时,我在 python 3 中运行了我的代码并发布了结果。我认为您使用的是 windows,因为在 python3 中的 linux 上,打印的字符串值前面没有 u(在我的示例中调用 j.type() 的结果),python 3 中的所有字符串默认情况下都是 unicode...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 2010-10-02
    • 1970-01-01
    • 2011-07-07
    相关资源
    最近更新 更多