代码如下:
#!/usr/bin/env python3
import _thread
import os
import random
import sys
import time
from collections import Counter
import PySimpleGUI as sg
#
def load_name_list(file='names.csv'):
with open(file, encoding="gbk") as f:
next(f) # 跳过标题行
lines = [line.strip().split(",")[0] for line in f]
return lines
#获取名称
names = load_name_list()
#判断是否有重复
counter = Counter(names)
print(counter.most_common(1))
name_count = counter.most_common(1)[0]
if name_count[1] != 1:
sg.popup(f"本地文件 names.csv 存在同名同姓{
name_count[0]},\n请手动改同名同姓加其他的值区分后,再重启程序继续", title="提示")
sys.exit(0)
#GUI开始
sg.change_look_and_feel("LightBlue")
#桌面控件
file_list_column = [
[sg.Text("待抽奖名