0
点赞
收藏
分享

微信扫一扫

Python 将有序list打乱随机排序


​random​​​模块下的​​shuffle​​​函数就可以打乱​​list​​。

from random import shuffle
l = [1, 2, 3, 4, 5]
shuffle(l)
print(l)
# [2, 3, 4, 5, 1]

参考:https://docs.python.org/3/library/random.html?highlight=random#random.shuffle


举报

相关推荐

0 条评论