擅长:python、mysql、java
<p>如果正则表达式没有在块中找到一个片段,它将返回一个空列表,从而返回错误。你知道吗</p>
<pre><code>>>> pieces = []
>>> pieces[-1]
IndexError: list index out of range
</code></pre>
<p>如果你希望在每一个块中找到一个片段,那么下一个问题是为什么你不能在一个特定的块中找到一个片段。我将继续调试如下</p>
<pre><code>try:
remainder = '{} {} '.format(*pieces[-1])
except IndexError:
print pieces
print chunk
raise
</code></pre>