问题
I was wondering how to reverse a list of lists in python. For example,
Original: list = [[1,2,3],[4,5,6],[7,8,9]]
Output: new_list = [[7,8,9],[4,5,6],[1,2,3]]
Right now, I am trying this:
new_list = reversed(list)
However, this doesn't seem to work.
回答1:
In [24]: L = [[1,2,3],[4,5,6],[7,8,9]]
In [25]: L[::-1]
Out[25]: [[7, 8, 9], [4, 5, 6], [1, 2, 3]]
来源:https://stackoverflow.com/questions/33578916/how-to-reverse-a-list-of-lists-in-python