思路:读入时按冒号split之后填成字典即可。
#sdut 查字典 while True: dic = {} n,m = input("").split(' ') n = int(n) m = int(m) if n==0 and m==0: break for i in range(n): item = input("").split(':') key = item[0] value = item[1].strip() dic[key] = value for i in range(m): word = input("") if word in dic: print(dic[word]) else: print("Not found!")