max(dic)返回字典中最大的Key值,max(dic,key=dic.get)返回字典中最大值values对应的key
#max(dic)返回字典中最大的Key值,max(dic,key=dic.get)返回字典中最大值values对应的key dic1={'a':4,'b':19,'c':2,'d':13} mask=max(dic1) mask2=max(dic1,key=dic1.get) print(" 该例子的字典为:{'a':4,'b':19,'c':2,'d':13}") print(" max(dic)返回的结果:",mask) print("max(dic,key=dic.get)返回的结果:",mask2) dic2={'a':4,'b':19,'e':2,'d':22} mask2=max(dic2) mask22=max(dic2,key=dic2.get) print(" -------------------------------------------") print("该例子的字典为:{'a':4,'b':19,'c':2,'d':13} ") print("max(dic)返回的结果:",mask2) print("max(dic,key=dic.get)返回的结果:",mask22)
结果:
END