<p>一行一行的清单</p>
<pre><code>input_string = "01-result.xls,2-result.xls,03-result.xls,05-result.xls"
result = [''.join(i.split('-')[::-1]).replace('.xls', '').replace('0', '') for i in input_string.split(',')]
</code></pre>
<p>结果</p>
<pre><code>['result1', 'result2', 'result3', 'result5']
</code></pre>
<p>这与</p>
<pre><code>result = []
for i in input_string.split(','):
formatted_element = ''.join(i.split('-')[::-1]).replace('.xls', '').replace('0', '')
result.append(formatted_element)
</code></pre>
<p>在您的情况下,您应该这样做:</p>
<pre><code>[Y.replace('0', '') for Y in newsplitted]
</code></pre>
<p>或者</p>
<pre><code>final = []
for Y in newsplitted :
final.append(Y.replace('0',''))
</code></pre>
<p>我建议您阅读更多关于python中列表理解的内容</p>
<p><a href="http://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/" rel="nofollow">http://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/</a></p>
<p>你可以随时查阅文件</p>
<p><a href="https://docs.python.org/3.5/tutorial/datastructures.html#list-comprehensions" rel="nofollow">https://docs.python.org/3.5/tutorial/datastructures.html#list-comprehensions</a></p>