我有一个数字列表,我想用一把钥匙对它进行洗牌并重做它。我使用它作为一个小的加密算法,所以我需要重新洗牌或从支持列表中获取原始列表。
original = [10, 20, 30, 25, 45, 68, 25]
shuffled = shuffle(original, key=10)
print shuffled
# >>> [25, 30, 25, 10, 20, 45, 68]
print re_shuffle(shuffled, key=10)
# >>> [10, 20, 30, 25, 45, 68, 25]
这就是我想要的想法。是否有库或算法?
答案 0 :(得分:0)
from random import shuffle
x = [[i] for i in range(10)]
shuffle(x)
print x