擅长:python、mysql、java
<p>您可以使用<code>filter</code>删除空字符串:</p>
<pre><code>import re
name = 'propane'
a = []
Alkane = list(map(lambda m: tuple(filter(bool, m)), re.findall('(\d+\W+)*(methyl|ethyl|propyl|butyl)*(meth|eth|prop|but|pent|hex)(ane)', name)))
if Alkane != a:
print(Alkane)
</code></pre>
<p>或者您可以使用列表/元组理解:</p>
^{pr2}$
<p>两种输出:</p>
<pre><code>[('prop', 'ane')]
</code></pre>