Python 如何正确引用列表列表中的项目

Python 如何正确引用列表列表中的项目,python,Python,我试图引用列表列表中的一个项目,但它只返回项目中的一个数字,而不是整个项目本身。让我来说明我的意思 # Let's say I have this list here L = [['201','304','514'],['312','143','224']] 如果我要这么做 L2 = L[0] print(L2[0]) red = 201 green = 304 blue = 514 结果应该是 '201' 对吗 在这种情况下,我的程序只向我回击了一个2,这是项目的第一个数字。这是我的一些

我试图引用列表列表中的一个项目,但它只返回项目中的一个数字,而不是整个项目本身。让我来说明我的意思

# Let's say I have this list here
L = [['201','304','514'],['312','143','224']]
如果我要这么做

L2 = L[0]
print(L2[0])
red = 201
green = 304
blue = 514
结果应该是 '201' 对吗

在这种情况下,我的程序只向我回击了一个2,这是项目的第一个数字。这是我的一些代码

zp = [list(t) for t in zip(*[iter(masterL)] * 3)]
# masterL is just a regular list and zp creates a list of lists grouped by 3
# similar to the list L stated above
count = 0
while count < len(zp):
     current_img = zp[count]
     for rgb in current_img:
         red = int(rgb[0])
         green = int(rgb[1])
         blue = int(rgb[2])
当我希望我的代码执行此操作时

L2 = L[0]
print(L2[0])
red = 201
green = 304
blue = 514

@第二次世界大战让我明白我走得太远了

为了得到我想要的结果,我的代码应该是这样的

# In the example above current_img would have looked like this
current_img = ['201', '304', '514']

# In order to get the output I wanted my code should have looked something like this
red = current_img[0]
green = current_img[1]
blue = current_img[2]

请为
masterL
提供一个示例。masterL=['201'、'304'、'514'、'312'、'143'、'224']
current\u img
zp
中的第一项,然后您对其进行迭代。打印
current\u img
rgb
以查看发生了什么。当我打印这些东西时,你需要增加
count
@wwii所以atm rgb=201和current\u img=['201','304','514']。我想我现在可能已经弄明白了,你也可以在zg中的当前img中使用
摆脱
计数
循环: