我想在每个匹配的新行上打印findall结果
import urllib.request
import re
htmlfile = urllib.request.urlopen("http://basketball.realgm.com/")
htmltext = htmlfile.read().decode('iso-8859-1')
title = re.findall('">(.+?)</a></h3>', htmltext)
print (title)
['LeBron James Exercises Early Termination Option With Heat', 'LeBron James Exercises Early Termination Option With Heat', 'Heat, Hawks Could Join Pursuit Of Carmelo Anthony', 'Tyler Dorsey Decommits From Arizona', 'Antoine Mason Transfers To Auburn', 'Dario Saric Signs Three-Year Deal With Anadolu Efes', 'Batum To Participate In FIBA World Cup For France', 'Moustapha Diagne Commits To Syracuse']
LeBron James Exercises Early Termination Option With Heat
Heat, Hawks Could Join Pursuit Of Carmelo Anthony
Tyler Dorsey Decommits From Arizona
尝试:
print (title \n)
答案 0 :(得分:3)
只做
print("\n".join(title))
答案 1 :(得分:2)
使用for
循环。
for t in title:
print(t)