# -*- coding:utf-8 -*-# Author:
# @Time:2019-08-05 10:08import os
import sys
import caipiao
import send_mail
def win_rules(num_list,last_results):
my_blue= num_list[0:5]
my_red= num_list[5:]
result_blue= last_results[0:5]
result_red= last_results[5:]
same_blue= [l for l in my_blue if l inresult_blue]
same_red= [l for l in my_red if l inresult_red ]
same_num_blue=len(same_blue)
same_num_red=len(same_red)
subject="大乐透中奖查询"content="未中奖"#9等奖if same_num_blue == 5 and same_num_red == 2:
print("\033[1;31;0m你已经中了一等奖,中奖号码为 %s \033[0m" %num_list)
content= "你已经中了一等奖,中奖号码为" +str(num_list)
elif same_num_blue== 5 and same_num_red == 1:
print("\033[1;35;0m你已经中了二等奖,中奖号码为 %s \033[0m" %num_list)
content= "你已经中了二等奖,中奖号码为" +str(num_list)
elif same_num_blue== 5:
print("\033[1;33;0m你已经中了三等奖, 中奖号码为 %s \033[0m" %num_list)
content= "你已经中了三等奖,中奖号码为" +str(num_list)
elif same_num_blue== 4 and same_num_red == 2:
print("\033[1;32;0m你已经中了四等奖, 中奖号码为 %s \033[0m" %num_list)
content= "你已经中了四等奖,中奖号码为" +str(num_list)
elif same_num_blue== 4 and same_num_red == 1:
print("\033[1;32;0m你已经中了五等奖, 中奖号码为 %s \033[0m" %num_list)
content= "你已经中了一等奖,中奖号码为" +str(num_list)
elif same_num_blue== 3 and same_num_red == 2:
print("\033[1;34;0m你已经中了六等奖, 中奖号码为 %s\033[0m" %num_list)
content= "你已经中了六等奖,中奖号码为" +str(num_list)
elif same_num_blue== 4:
print("\033[1;34;0m你已经中了七等奖, 中奖号码为 %s \033[0m" %num_list)
content= "你已经中了七等奖,中奖号码为" +str(num_list)
elif (same_num_blue== 2 and same_num_red == 2) or (same_num_blue == 3 and same_num_red == 1):
print("\033[1;34;0m你已经中了八等奖, 中奖号码为 %s \033[0m" %num_list)
content= "你已经中了八等奖,中奖号码为" +str(num_list)
elif (same_num_blue== 1 and same_num_red == 2) or (same_num_red == 2) or (same_num_blue == 2 and same_num_red == 1):
print("\033[1;36;0m你已经中了九等奖, 中奖号码为 %s \033[0m" %num_list)
content= "你已经中了九等奖,中奖号码为" +str(num_list)else:
print("sorry,你没有中奖!!!")
content= "未中奖"+ "本次开奖号码为"+str(last_results)
send_mail.mail(subject, content)if __name__ == '__main__':
caipiao.get_winnum()
datepath= datapath = sys.path[0]
fname="lot_500_dlt.txt"fmy_num="my_num.txt"with open(datapath+'/'+ fname,'r') asf:
lines=f.readlines() #读取所有行
last_line= lines[-1].strip('\n')
#获取最新的彩票号码
last_results=last_line.split(",")[1:]
#查询是否中奖,获取自己的号码
with open(datapath+'/'+ fmy_num,'r') asf:
lines=f.readlines()for i inlines:
i=i.strip('\n')
num=i.split(',')
win_rules(num,last_results)