给我们工会主席写的小代码
import pandas as pd
import random
import os
# 读取人员姓名
ospath = os.getcwd()
df = pd.read_excel(ospath + r'\人员.xlsx', header=None)
total_people = df.shape[0]
zu_ct = int(total_people / 3)
print('玩家总人数为{}, 3人一组,共分{}组'.format(total_people, zu_ct))
# 随机排序
a = [i for i in range(1, total_people + 1)]
random.shuffle(a)
df['乱序'] = a
df.sort_values("乱序", inplace=True)
df_result = pd.DataFrame(pd.DataFrame(df.iloc[:, 0]).values.reshape(zu_ct, 3))
print('随机分组-----done')
# 保存结果
df_result.columns = ['成员1', '成员2', '成员3']
row_name = ['第' + str(i) + '组' for i in range(1, zu_ct + 1)]
df_result.index = row_name
df_result.to_excel(ospath + r'\人员_随机分组结果.xlsx')
print('结果保存在当前目录《人员_随机分组结果.xlsx》-----done')
print('over')
最后形成exe小工具