擅长:python、mysql、java
<p>这将正确解析示例文件:</p>
<pre><code>with open('yourfile') as f:
result = {'have paid': [], '': []}
current = []
for line in f:
line = line.strip().strip('-')
if line in result:
result[line].extend(current)
current = []
else:
current.append(line)
print 'These have paid:', ','.join(result['have paid'])
print 'These have not paid:', ','.join(result[''])
</code></pre>
<p>结果:</p>
^{pr2}$