小编tit*_*ban的帖子

Python:给定项目的2D列表中的索引返回2个整数

这个星期我一直在修补python,我陷入了困境.如果我有这样的2D列表:myList = [[1,2],[3,4],[5,6]]

我这样做了

myList = [[1,2],[3,4],[5,6]]
Run Code Online (Sandbox Code Playgroud)

它会回来

>>>myList.index([3,4])
Run Code Online (Sandbox Code Playgroud)

但是,我想要列表中的某些内容的索引,就像这样

1
Run Code Online (Sandbox Code Playgroud)

它会回来的

    >>>myList.index(3)
Run Code Online (Sandbox Code Playgroud)

有什么可以做到这一点?

干杯

python nested-lists

10
推荐指数
2
解决办法
1万
查看次数

标签 统计

nested-lists ×1

python ×1