Python抽奖系统
#免费源码见文末公众号#
抽奖系统①
def choujiang1():def write():with open('d:\\抽奖系统\\抽奖1.1.pickle','rb') as file:lst1=pickle.load(file)name=var1.get()if name not in lst1 and name!='录入成功!' and name!='录入失败!' and name!='':lst1.append(name)var1.set('录入成功!')else:var1.set('录入失败!')with open('d:\\抽奖系统\\抽奖1.1.pickle','wb') as file:pickle.dump(lst1,file)file.close()with open('d:\\抽奖系统\\抽奖1.2.pickle','rb') as file:lst2=pickle.load(file)gift=var2.get()if gift not in lst2 and gift!='录入成功!' and gift!='录入失败!' and gift !='':lst2.append(gift)var2.set('录入成功!')else:var2.set('录入失败!')with open('d:\\抽奖系统\\抽奖1.2.pickle','wb') as file:pickle.dump(lst2,file)file.close()def choice():with open('d:\\抽奖系统\\抽奖1.1.pickle','rb') as file:lst1=pickle.load(file)with open('d:\\抽奖系统\\抽奖1.2.pickle','rb') as file:lst2=pickle.load(file)names=var3.get()if names in lst1:lst1.remove(names)if len(lst2)==0:var4.set('没有礼物了!')else:t=r.randint(0,len(lst2)-1)var4.set(lst2[t])lst2.remove(lst2[t])else:var4.set('查无此人!')
抽奖系统②
def choujiang2():lst=[i for i in range(0,100)] #管理员设置奖品with open('d:\\抽奖系统\\抽奖2.pickle','wb') as file:pickle.dump(lst,file)file.close()def choujiang_2_():with open("d:\\抽奖系统\\抽奖2.pickle",'rb') as file:lst=pickle.load(file)if lst:t=r.randint(0,len(lst)-1)var.set(lst[t])lst.remove(lst[t])with open('d:\\抽奖系统\\抽奖2.pickle','wb') as file:pickle.dump(lst,file)file.close()else:var.set(' 没有奖品了!')
抽奖系统③
def choujiang3():def gifts():global flag1if flag1==1:gift=var2.get()with open('d:\\抽奖系统\\抽奖3.pickle','rb') as file:lst=pickle.load(file)lst.append(gift)file.close()with open('d:\\抽奖系统\\抽奖3.pickle','wb') as file:pickle.dump(lst,file)file.close()else:var2.set('ERROR!')def keys():global flag1key=var1.get()if key==user_keys:flag1=1var1.set('欢迎管理员进入系统!')else:var1.set('管理员密码错误!')def choice():with open('d:\\抽奖系统\\抽奖3.pickle','rb') as file:lst=pickle.load(file)if len(lst)!=0:t=r.randint(0,len(lst)-1)var3.set(lst[t])lst.remove(lst[t])else:var3.set('ERROR!')with open('d:\\抽奖系统\\抽奖3.pickle','wb') as file:pickle.dump(lst,file)file.close()def end():global flag1flag1=0