我在堆栈溢出附近找到了这个问题Removing Duplicates From Dictionary
另一个问题的人也有我的问题。我试过他们给他的解决办法,但都不管用。你能帮助我吗?在
这是我的单子。下面是我的代码:def printed(filename, day, time):
try:
result = {}
f = open(filename, 'r')
lines = f.readlines()
d = defaultdict(list)
start = lines.index(day+"\n")
if day == 'Monday\n':
stop = lines.index("Saturday\n")
elif day == 'Saturday\n':
stop = lines.index("Sunday\n")
else:
stop = len(lines)
if filename == "Bus 6 Cornaredo.txt" and filename == "Bus 6 Lugano Stazione.txt":
if day == "Sunday":
return "There are no buses this day for Bus 6"
else:
for line in lines[start:stop]:
line = line.replace('