【发布时间】:2015-04-22 11:49:22
【问题描述】:
我将 Python 2.7 与 Autodesk Maya 结合使用。这是我的问题的一个例子:
import maya.cmds as m
def a(passedString):
print('this'+passedString)
def b(passedString):
print('that'+passedString)
def c(passedString):
print('notThis'+passedString)
def d(passedString):
print('ofCourse'+passedString)
string1 = [a(),b(),c(),d()]
string2 = [poly1,poly2,poly3,poly4]
for each in string2 and every in string1:
m.select(each)
every(each)
这可能看起来很简单,但我需要用string1[0] 执行string2[0](一个函数)并且只有 string1[0]。
下一个数组项也是如此。 [1] with [1] and [2] with [2] and [3] with [3].
基本上,我是在尝试减少代码并简化代码的执行方式,而不是为 20 多个单独的实例繁琐地编写上述代码。
【问题讨论】:
-
你可能想做:
string1 = [a,b,c,d] -
注意到了,Alfasin。
标签: python string function python-2.7 maya