如下所示:
>>> 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
以上这篇python 中字典嵌套列表的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。