今天爱分享给大家带来打乱一个排好序的list对象alist?【面试题详解】,希望能够帮助到大家。
import random
alist = [1,2,3,4,5]
random.shuffle(alist)
print(alist)
# 下面这段代码是shuffle的实现
items = list(alist)
for i in xrange(len(alist)):
alist[i] = items.pop(self.randrange(len(items)))
原文链接:https://blog.itblood.com/3975.html,转载请注明出处。

![刀剑江湖路 Ver1.0.1.2 官方中文 绅士MOD整合版 地牢调教+角色美化+乱伦+额外角色+卖春[新整合][14.7G] [武侠RPG/中文/开放世界]](/wp-content/uploads/replace/2025/09/18/6d54fe907cc554a92424a2df4874b4d1.webp)