<p>一个字符串可以被拆分,一些单词可以被赋给一个元组吗?</p>
<p>例如:</p>
<pre><code>a = "Jack and Jill went up the hill"
(user1, user2) = a.split().pick(1,3) # picks 1 and 3 element in the list.
</code></pre>
<p>这样的单程航班有可能吗?如果是,语法是什么。</p>
<p>切片支持步骤参数</p>
<pre><code>a = "Jack and Jill went up the hill"
(user1 , user2) = a.split()[0:4:2] #picks 1 and 3 element in the list
</code></pre>
<p>但是,虽然用Python编写时髦的单行程序是可能的,但它肯定不是进行这种练习的最佳语言。</p>