Ale*_*exZ 11 python dictionary
d = {
"local": {
"count": 1,
"health-beauty": {
"count": 1,
"tanning": {"count": 1}
}
},
"nationwide": {"count": 9.0},
"travel": {"count": 0}
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中"nationwide"是最大的.
代码如下,以便更容易附加到脚本:
d = {'travel': {'count': 0}, 'local': {'count': 1, 'health-beauty': {'count': 1, 'tanning': {'count': 1}}}, 'nationwide': {'count': 9.0}}
Run Code Online (Sandbox Code Playgroud)
JBe*_*rdo 12
>>> max(d, key=lambda x: d[x]['count'])
'nationwide'
Run Code Online (Sandbox Code Playgroud)