Python:shuffle(a) 打亂array或list的順序,原始的可迭代對象中元素順序打亂,但原始對象的類別不變

import numpy as np

a = np.array(range(20))
print("a=",a)
b = np.arange(20)
print("b=",b)
s_a = np.random.shuffle(a)
s_b = np.random.shuffle(b)
print(s_a)
print(s_b)
print("a=",a)
print("b=",b)
print(type(b))
print()
c = list(range(10))
print(c)
s_c = np.random.shuffle(c)
print(c)
print(type(c))

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章