a=[{'1st innings': {'team': 'Islamabad United',
'deliveries': [{0.1: {'non_striker': 'Sharjeel Khan',
'bowler': 'Anwar Ali',
'runs': {'extras': 0, 'total': 0, 'batsman': 0},
'batsman': 'SR Watson'}},
{0.2: {'non_striker': 'Sharjeel Khan',
'bowler': 'Anwar Ali',
'runs': {'extras': 0, 'total': 0, 'batsman': 0},
'batsman': 'SR Watson'}},
{0.3: {'non_striker': 'Sharjeel Khan',
'bowler': 'Anwar Ali',
'runs': {'extras': 0, 'total': 0, 'batsman': 0},
'batsman': 'SR Watson'}},
{0.4: {'non_striker': 'Sharjeel Khan',
'bowler': 'Anwar Ali',
'runs': {'extras': 0, 'total': 0, 'batsman': 0},
'batsman': 'SR Watson'}},
{0.5: {'non_striker': 'Sharjeel Khan',
'bowler': 'Anwar Ali',
'runs': {'extras': 0, 'total': 0, 'batsman': 0},
'batsman': 'SR Watson'}},
{0.6: {'non_striker': 'Sharjeel Khan',
'bowler': 'Anwar Ali',
'runs': {'extras': 0, 'total': 0, 'batsman': 0},
'batsman': 'SR Watson'}}}]
如何访问这本词典的不同索引,即python中的“第一局”、“击球手”、“全场”等
当我尝试使用[“1st innings”]访问第一局时,我不断收到错误“typeerror:列表索引必须是整数或片,而不是str”
1条答案
按热度按时间ctehm74n1#
你有一个-
list
属于dicts
. 所以你需要像