import random
from copy import deepcopy
def member_shuffle(input_list) :
tmp_list = deepcopy(input_list)
random.shuffle(tmp_list)
return tmp_list
def member_move(input_list) :
step = random.randint(1,len(input_list)-1)
return (input_list + input_list)[step:step+len(input_list)]
member_list = ['a','b','c','d','e','f']
shuffled_member_list = member_shuffle(member_list)
moved_member_list = member_move(shuffled_member_list)
for member in member_list :
give_to = moved_member_list[shuffled_member_list.index(member)]
print('{} 送礼给 {}'.format(member,give_to))
输出:
a 送礼给 b
b 送礼给 a
c 送礼给 e
d 送礼给 f
e 送礼给 c
f 送礼给 d
理科圣诞节要交换礼物这么麻烦
不能线上用个抽签系统就好吗