删除列表列表中的第一项 - 制作副本而不是就地修改

Remove the first items in a list of lists - make a copy instead of modifying in-place

设数组a为:

a = [[1, 2], [1, 2, 3], [1, 2, 3, 4]]

如何获得以下列表?

b = [[2], [2, 3], [2, 3, 4]]

嗯,对于这个例子,你可以使用 list comprehension with slicing

a = [[1, 2], [1, 2, 3], [1, 2, 3, 4]]
b = [x[1:] for x in a]