这是代码,它应该从文件中读取然后生成字典...
def get_songs(setlists):
f = file(setlists)
d = {}
next_line = f.readline()
while (next_line != ""):
if next_line[0].isdigit():
concert1 = concert(int(next_line.split("-")[0]) , int(next_line.split("-")[1]) , \
int(next_line.split("-")[2]) , next_line.split("-")[3].strip("\n"))
for i in f.readline().split('/'):
d[i.strip(" ").strip("\n").split("(")[0]] = (concert1 if not d.has_key(i.strip(" ").strip("\n").split("(")[0])
else ([d[i.strip(" ").strip("\n").split("(")[0]] , concert1] if
isinstance(d[i.strip(" ").strip("\n").split("(")[0]] , concert)
else d[i.strip(" ").strip("\n").split("(")[0]] + [concert1]))
next_line = f.readline()
return d