擅长:python、mysql、java
<p><code>arg.split()</code>未按您希望的方式拆分列表,因为默认分隔符与您的不匹配:</p>
<pre><code>In [3]: arg
Out[3]: 'egg1, egg2'
In [4]: arg.split()
Out[4]: ['egg1,', 'egg2']
In [5]: arg.split(', ')
Out[5]: ['egg1', 'egg2']
</code></pre>
<p>从<a href="http://docs.python.org/library/stdtypes.html#str.split" rel="nofollow">the docs</a>(加上强调):</p>
<blockquote>
<p>If sep is not specified or is <code>None</code>, a different splitting algorithm is applied: <strong>runs of consecutive whitespace are regarded as a single separator</strong>, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace.</p>
</blockquote>