我在Python中有一个对象列表,我想要将它们混洗.我以为我可以使用该random.shuffle方法,但当列表是对象时,这似乎失败了.是否有一种方法可以改变对象或其他方式?
random.shuffle
import random class A: foo = "bar" a1 = a() a2 = a() b = [a1, a2] print(random.shuffle(b))
这将失败.
python random shuffle list
list ×1
python ×1
random ×1
shuffle ×1