amr*_*csu 11 python random list
我想知道是否有一种很好的方法来"动摇"Python中的项目列表.例如,[1,2,3,4,5]可能会被动摇/随机化[3,1,4,2,5](任何有序的排序).
rog*_*osh 36
from random import shuffle
list1 = [1,2,3,4,5]
shuffle(list1)
print list1
---> [3, 1, 2, 4, 5]
Run Code Online (Sandbox Code Playgroud)