Python Shuffle Array: Randomize Order
You can use the shuffle function in the random module to randomize the order of an array. Here is an example code:
import random
# 定义一个数组
array = [1, 2, 3, 4, 5]
# 打乱数组的顺序
random.shuffle(array)
# 打印打乱后的数组
print(array)
Running the above code will generate an array with a shuffled order.