擅长:python、mysql、java
<p>你可以试试</p>
<pre class="lang-python prettyprint-override"><code>myVariable = 'iheoiahwd'
idxs = [0, 3, 4, 6, 7]
myVariable = [myVariable[i] for i in idxs]
print ''.join(myVariable)
</code></pre>
<p>或简化为一行:</p>
<pre><code>print ''.join([myVariable[i] for i in [0, 3, 4, 6, 7]])
</code></pre>