SoFunction
Updated on 2024-11-15

Specific uses of python [::-1] [::-1,::-1]

I. [::-1]

在这里插入图片描述

import numpy as np
import numpy as np
x = (1, 6)
print("Original array:")
print(x)
print("Reverse array:")
x = x[::-1]
print(x)

'''
Original array:
[1 2 3 4 5]
Reverse array:
[5 4 3 2 1]
'''

[::-1] : will output the elements of the array in reverse direction

在这里插入图片描述

II. [::-1,::-1]

nums=([[1,2,3,4],
              [5,6,7,8],
              [9,10,11,12],
              [13,14,15,16]])
print(nums[::-1,::-1])

'''
[[16 15 14 13]
 [12 11 10  9]
 [ 8  7  6  5]
 [ 4  3  2  1]]
'''

在这里插入图片描述

to this article on the specific use of python [::-1] [::-1,::-1] article on this, more related python [::-1] [::-1,::-1,::-1] content, please search for my previous posts or continue to browse the following related articles I hope that you will support me in the future!