python 中好用的函数,random.sample等,持续更新 random.sample random.sample的函数原型为:random.sample(sequence, k),从指定序列中随机获取指定长度的片断.sample函数不会修改原有序列 import random list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] slice = random.sample(list, 5) # 从list中随机获取5个元素,作为一个片断返回 print(slic