下面提到的字典值
dict = {'Incident, INC': 'Incident',
'SR, Service Request': 'Service Request',
'RCA ticket, Task': 'Problem',
'OCM, Alert': 'Change',
'Change': 'Minor enhancements'}
我需要将字典值Map到
expect dictionary = {
'INC': 'Incident',
'Incident': 'Incident',
'Inc': 'Incident',
'Change': 'Minor Enchancement',
'SR': 'ServiceRequest',
'ServiceRequest': 'ServiceRequest'
}
我需要添加多个条件给定字典将读取给定列表,如果任何值匹配它应该dict值,否则它应该返回像Unspecified
。
输入----〉
new_list= ['Incident','INC','SR','Change','ABC']
预期产出---〉
new_list = ['Incident','Incident','Minor Enchancement','Service Request','others']
我的密码不起作用。
reversed_dict = {}
for key in my_dict:
items = [x.strip() for x in my_dict[key].split()]
for i in items:
reversed_dict[i] = key
1条答案
按热度按时间qlvxas9a1#
这就是你要找的吗?
退货: