方法1:
# 根据字典的值value获得该值对应的key
def get_dict_key(dic, value):
keys = list(dic.keys())
values = list(dic.values())
idx = values.index(value)
key = keys[idx]
return key
方法2:
# 根据字典的值value获得该值对应的key
def get_dict_key(dic, value):
key = list(dic.keys())[list(dic.values()).index(value)]
return key