python 中的多个方括号
Multiple square brackets in python
def startpop(pop,job):
i = 0
L = [[[(random.uniform(1,0))]]]
while i < pop:
k = 0
if len(L) <= i:
L.append([[random.uniform(1,0)]])
我正在尝试理解这段代码。三个方括号是什么意思?
是否只是一个list in a list中的list:
[
[
[
(random.uniform(1,0))
]
]
]
即
>>> test = [[[1,2]]]
>>> print test[0]
[[1,2]]
>>> print test[0][0]
[1,2]
>>> print test[0][0][0]
1
def startpop(pop,job):
i = 0
L = [[[(random.uniform(1,0))]]]
while i < pop:
k = 0
if len(L) <= i:
L.append([[random.uniform(1,0)]])
我正在尝试理解这段代码。三个方括号是什么意思?
是否只是一个list in a list中的list:
[
[
[
(random.uniform(1,0))
]
]
]
即
>>> test = [[[1,2]]]
>>> print test[0]
[[1,2]]
>>> print test[0][0]
[1,2]
>>> print test[0][0][0]
1