<p><a href="http://docs.python.org/2/library/string.html#string.strip">^{<cd1>}</a>是字符串的方法,您是在<code>list</code>上调用它的,因此出现错误。</p>
<pre><code>>>> 'strip' in dir(str)
True
>>> 'strip' in dir(list)
False
</code></pre>
<p>做你想做的,就做</p>
<pre><code>>>> l = ['Facebook;Google+;MySpace', 'Apple;Android']
>>> l1 = [elem.strip().split(';') for elem in l]
>>> print l1
[['Facebook', 'Google+', 'MySpace'], ['Apple', 'Android']]
</code></pre>
<p>因为,您希望元素位于单个列表(而不是列表列表)中,所以有两个选项。</p>
<ol>
<li>创建一个空列表并向其追加元素。</li>
<li>将列表展平。</li>
</ol>
<p>要执行第一个操作,请遵循以下代码:</p>
<pre><code>>>> l1 = []
>>> for elem in l:
l1.extend(elem.strip().split(';'))
>>> l1
['Facebook', 'Google+', 'MySpace', 'Apple', 'Android']
</code></pre>
<p>要执行第二个操作,请使用<a href="http://docs.python.org/2/library/itertools.html#itertools.chain">^{<cd3>}</a></p>
<pre><code>>>> l1 = [elem.strip().split(';') for elem in l]
>>> print l1
[['Facebook', 'Google+', 'MySpace'], ['Apple', 'Android']]
>>> from itertools import chain
>>> list(chain(*l1))
['Facebook', 'Google+', 'MySpace', 'Apple', 'Android']
</code></pre>