代码如下:
import random
aa = [1, 2, 3, 4, 5, 6]
bb = [1, 2, 3, 4, 5, 6]
cc = list(zip(aa, bb))
random.shuffle(cc)
aa[:], bb[:] = zip(*cc)
print(aa, bb)
# 输出为:[1, 3, 5, 2, 4, 6] [1, 3, 5, 2, 4, 6]
Reference:
1. 参考代码:https://www.cnblogs.com/huangshiyu13/p/6917789.html
2. zip函数介绍:http://www.runoob.com/python/python-func-zip.html