【发布时间】:2019-04-04 01:17:12
【问题描述】:
你好,这是我第一次使用 python
我有一本字典:
players= {"Gehrig":{"atBats":8061, "hits":2721},
"Ruth":{"atBats":8399, "hits":2873},
"Williams":{"atBats":7706, "hits":2654}}
我想找出三个玩家中任何一个的命中率最高。
期望的输出:
The most hits by one of the
players was 2873.
我的意见:
max(players.hits())
maximum = max(players,key=players.get)
max(players,key=players.get)
但我只收到如下错误:
TypeError: '>' not supported between instances of 'dict' and 'dict'
我需要改变什么?
【问题讨论】:
标签: python dictionary syntax max