擅长:python、mysql、java
<p>纯Python:</p>
<pre><code>text = """Ring Ring (ABBA (1973))
Waterloo (ABBA) (1974)
If I Don’t Write This Song Someone I Love Will Die (Hello Saferide) (2005)
My Best Friend (Hello Saferide (2005))"""
text = text.split("\n")
songs = {}
for song in text:
name = song.split("(")[0]
band = song.split("(")[1].split(" ")[0]
year = song.split("(")[2]
band = band.replace(")","")
year = year.replace(")","")
print("band",band,"year",year,"song",name)
songs[name] = {"year":year,"band":band}
print(songs)
</code></pre>