小编Jar*_*red的帖子

如何将列表中的最后一项移到python的前面?

我彻底搜查了但找不到与此具体相关的任何内容.我有一个清单:

a = [two, three, one]
Run Code Online (Sandbox Code Playgroud)

我想移到one前面,所以它变成:

a = [one, two, three]
Run Code Online (Sandbox Code Playgroud)

问题是,它可能是列表中的任意数量.假设无法知道是否会有50个项目或3个项目.

python list

16
推荐指数
3
解决办法
2万
查看次数

在Python中一次迭代三个列表?

这可能是一个相当复杂的问题,因为很多人可能不知道我正在为它编写的软件:Autodesk Maya 2011.我正在尝试加快一个繁琐的缓慢过程(操纵:赋予3d角色能力)通过编写自动执行的脚本来移动.

我会尽力解释这种情况.

我有一个脚本,它接受一个对象,遍历该对象的子节点,将它们存储在列表中,然后将初始对象放在列表的末尾,反转列表,因为它是错误的方法,然后放置初始对象在前面.

问题:有三个不同的列表,所有相同的对象TYPE但具有不同的名称,它们实际上是不同的对象.我的目标是通过生成称为"blendcolors"的节点将它们连接在一起.但是,如果我有一个循环为列表A中的每个对象生成它们,那么我需要循环也将它们连接到其他列表中的对象,我无法弄清楚这一点.

这是我的代码,它已被播放,因此就实际循环而言,比以前更加不完整.

    import maya.cmds as cmds

    def crBC(IKJoint, FKJoint, bindJoint, xQuan, switch):

        # gets children joints of the selected joint
        chHipIK = cmds.listRelatives(IKJoint, ad = True, type = 'joint')
        chHipFK = cmds.listRelatives(FKJoint, ad = True, type = 'joint')
        chHipBind = cmds.listRelatives(bindJoint, ad = True, type = 'joint')
        # list is built backwards, this reverses the list
        chHipIK.reverse()
        chHipFK.reverse()
        chHipBind.reverse()
        # appends the initial joint to the list
        chHipIK.append(IKJoint)
        chHipFK.append(FKJoint)
        chHipBind.append(bindJoint)
        # puts the last joint …
Run Code Online (Sandbox Code Playgroud)

python maya

6
推荐指数
1
解决办法
8746
查看次数

标签 统计

python ×2

list ×1

maya ×1