2024-10-05 10:00:25 发布
网友
例如,请参见以下代码:
{0.1: {'batsman': 'SC Ganguly', 'bowler': 'P Kumar', 'runs': \ {'batsman': 0, 'total': 1, 'extras': 1}, \ 'extras': {'legbyes': 1}, \ 'non_striker': 'BB McCullum'}}
我想访问字典中的运行和键-如何访问它
这实际上是访问位于dictionary内部的dictionary中的值
可以为嵌套词典链接词典键索引器。举个例子:
d[0.1]['runs']
输出:
{'batsman': 0, 'extras': 1, 'total': 1}
我将您的词典定义为d,如下所示:
d
d = {0.1: {'batsman': 'SC Ganguly', 'bowler': 'P Kumar', 'runs': \ {'batsman': 0, 'total': 1, 'extras': 1}, \ 'extras': {'legbyes': 1}, \ 'non_striker': 'BB McCullum'}}
可以为嵌套词典链接词典键索引器。举个例子:
输出:
我将您的词典定义为
d
,如下所示:相关问题 更多 >
编程相关推荐