当前位置:主页 > 软件编程 > Python代码 >

python 中字典嵌套列表的方法

时间:2020-12-22 18:00:19 | 栏目:Python代码 | 点击:

如下所示:

>>> dict={}
>>> dict['list']=[]
>>> dict['list'].append([1,2,3,4])
>>> dict['list'].append([5,6,7])
>>> dict['list'].append([7,8,9,0,10])

输出字典:

>>> dict
{'list': [[1, 2, 3, 4], [5, 6, 7], [7, 8, 9, 0, 10]]}
>>> dict['list']
[[1, 2, 3, 4], [5, 6, 7], [7, 8, 9, 0, 10]]

相关操作:

>>> len(dict['list'])
3
>>> dict['list'][1]
[5, 6, 7]
>>> dict['list'][0][2]
3
>>> len(dict['list'][0])
4
>>> len(dict['list'][1])
3

您可能感兴趣的文章:

相关文章