擅长:python、mysql、java
<p>在python3.2中,<a href="https://docs.python.org/3/library/itertools.html#itertools.accumulate" rel="nofollow">itertools.accumulate</a>允许我们避免使用索引</p>
<pre><code>from itertools import accumulate
s = 'MayaWindow|toolBar2|MainShelfLayout|formLayout14|ShelfLayout|Custom'
new_list = list(accumulate(s.split('|'), lambda x,y: '|'.join((x,y))))
print(new_list)
</code></pre>
<p>生产</p>
^{pr2}$
<p>另一方面,在python2中,您可以沿着这条线做一些事情</p>
^{3}$