扩展字典的类
class ValueDict(dict): def __init__(self,*args,**kargs): super().__init__(*args,**kargs) def getValueByKey(self,val): result = [] for key,values in self.items(): if values == val: result.append(key) return result new = ValueDict(name="shun",name2="shun",name3="shunshun") print(new.getValueByKey("shun"))