取出的數(shù)據(jù)可以重復(fù)
need=[random.randint(0,100) for _ in range(要取出的數(shù)據(jù)條數(shù))]
# 隨機(jī)抽取3個(gè)測(cè)試題
exam_choice_list = [random.choice(exam_msg_list) for _ in range(3)]
image.png
取出的數(shù)據(jù)不能重復(fù)
need = random.sample([要取數(shù)據(jù)的列表], 要取出的數(shù)據(jù)個(gè)數(shù))
exam_choice_list = random.sample(exam_msg_list, 3)
image.png