import maya.cmds as mc
def jointHierarchy(topJoint , lastJoint = True):
jointsLists = mc.listRelatives(topJoint , type = 'joint' , ad = True)
jointsLists .append (topJoint)
jointsLists . reversed()
wholeChane = jointsLists [:]
if not lastJoint:
jointsWithoutEnd = [ j for j in jointsLists if mc.listRelatives( j , type = 'joint' ,c =1 )]
这是什么样的循环
'''
if not lastJoint:
jointsWithoutEnd = [ j for j in jointsLists if mc.listRelatives( j , type = 'joint' ,c =1 )]
'''
我们有这样的结构
j for j in jointsLists if mc.listRelatives( j , type = 'joint' ,c =1 )
我尝试了这段代码并且工作正常
任何帮助
答案 0 :(得分:1)
这就像:
jointsWithoutEnd=[]
for j in jointsLists:
if mc.listRelatives(j,type='joint',c=1):
jointsWithoutEnd.append(j)
编辑:正如RobertB所说,这就是列表理解:https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions 希望有所帮助。