dogdistance = {'dog-dog': 33, 'dog-cat': 36, 'dog-car': 41, 'dog-bird': 42}

min(dogdistance, key=dogdistance.get)

返回最小值的键值: 'dog-dog'

max(dogdistance, key=dogdistance.get)

返回最大值的键值: 'dog-bird'

 

这里key的用法为一个函数

 

参考:

https://docs.python.org/3/library/functions.html#max

https://blog.csdn.net/weixin_41770169/article/details/80816886

相关文章:

  • 2021-09-27
  • 2021-08-25
  • 2022-02-19
  • 2022-03-04
  • 2021-11-26
  • 2022-02-22
  • 2021-06-06
  • 2021-08-31
猜你喜欢
  • 2021-06-07
  • 2021-12-20
  • 2021-11-17
  • 2022-12-23
  • 2018-06-22
  • 2021-10-05
  • 2022-12-23
相关资源
相似解决方案