import maya.cmds as cmds
def createOffsetGrp(objSel):
# isinstance is used to check the type of the variable :
# i.e: isinstance(objSel, int)
# basestring is a type combining unicode and string types
if isinstance(objSel, basestring):
objSel = [objSel]
for obj in objSel:
p = cmds.listRelatives(obj,parent=True)
print (p)
createOffsetGrp('spine02_jnt')
多亏了Python中的duck类型,有时这样的错误很难捕捉到。这里发生的是你的函数需要一个数组作为参数,但是你传递的是一个字符串。在
Python还通过列出单个字符来支持对字符串进行迭代,这就是它在
spine02_jnt
中查找s
的原因。在数组中传递字符串可以解决您的问题:你能提供什么样的支持
相关问题 更多 >
编程相关推荐