擅长:python、mysql、java
<p>把答案再扩大一点。你知道吗</p>
<p>您可能希望执行<code>pmc.polySphere()</code>只会得到它的变换,但它实际上返回了它的变换和形状节点的列表:<code>[nt.Transform(u'pSphere1'), nt.PolySphere(u'polySphere1')]</code></p>
<p>您可以这样分配变量:</p>
<pre><code>sphereObj = pmc.polySphere()
xform = sphereObj[0]
shape = sphereObj[1]
</code></pre>
<p>但是,一次性将列表解包并分配给变量更具可读性和python风格:</p>
<pre><code>xform, shape = pmc.polySphere()
</code></pre>
<p>只要你知道列表的长度,你就可以把它做成一行:</p>
<pre><code>a, b, c, d = [1, 2, 3, 4]
</code></pre>
<p>但大多数情况下,您可能只需要转换,因此您也可以始终这样做:</p>
<pre><code>xform = pmc.polySphere()[0]
</code></pre>