import random
def sort():
list_0 = ['A', 'B', 'C', 'D', 'E', 'F', 'G'] # 列表不能设置中间变量(等同于原变量)
list_1 = []
while len(list_0) > 0:
# 随机生成索引
x = random.randint(0, len(list_0) - 1)
list_1.append(list_0[x])
list_0.pop(x)
print(list_1)
for _ in range(10):
sort()
python_打乱已知列表的顺序
最新推荐文章于 2024-10-29 17:35:02 发布