隨機(jī)取 list 中的元素 random.sample import random a = [1, 2, 3, 4, 5, 6, 7, 8, 9] b = random.sample(a, 5)