#字典值相加 def union_dic(*objs): _keys = set(sum([obj.keys() for obj in objs],[])) _total = {} for _key in _keys: _total[_key] = sum([obj.get(_key,0) for obj in objs]) return _total
1 # 字典如下 2 movie = { 3 '妖猫传':['黄','染'], 4 '无问西东':['章','王'], 5 '超时空':['雷','佟'] 6 } 7 name = input('请输入演员的名字') # 收集信息 8 for i in movie: # 遍历字典movie的键名 9 actor = movie[i] # 设置一变量actor等于遍历的字典值 10 if name in actor: # 如果输入的演员名字在遍历的值中 11 print(name + '出演了'+