擅长:python、mysql、java
<p>您使用的是列表而不是字符串</p>
<pre><code>import re
terms = ['The Beehive', '12. Bar 821', '13. Natives Bar', '14. Last Call Bar', '15. Scarlet Lounge', '16. Linden Room', '17. Rooftop 25']
delim = re.compile('\d+\.')
for term in terms:
match = delim.search(term)
if match:
print(term[:match.end()]) #index
print(term[match.end():]) #name
</code></pre>