擅长:python、mysql、java
<blockquote>
<p>Basically, I want to create a variable that will take the first value in the array (in this case, 1), and spit out the difference of each element from that value:</p>
</blockquote>
<p>对象<code>A</code>指向一个<code>tuple</code>而不是一个列表或数组</p>
<p>下面是您应该如何使用<a href="https://stackoverflow.com/questions/16940293/why-is-there-no-tuple-comprehension-in-python">generator expression</a>实现这一点(Python中的一行程序):</p>
<pre><code>A = (1, 3, 5, 5, 2, 4, 6)
print(tuple(i - li[0] for i in A))
</code></pre>
<p>产出:</p>
<pre><code>(0, 2, 4, 4, 1, 3, 5)
</code></pre>