python 学习贴 抽取,倒计时,爬取抽取,爬取预约hpv
- bbbzzz东拼西凑的一个东西权重随机抽取,最后打包exe大概5MB大小的exe复制代码
- # coding:utf-8import random #导入随机函数import timeimport os
- list = ['第1名中奖', '第2名中奖', '第3名中奖', '第4名中奖'] #随机序列选项
- print("输入4个权重值以空格键隔开,回车后此程序将自动按输入的权重值给出1-4名中权重随机选项") #提示输入权重值参数信息
- arr = input("") #输入一个一维数组,每个数之间使空格隔开num = [int(n) for n in arr.split()] #将输入每个数以空格键隔开做成数组
- def weight_choice(weight): """ :param weight: list对应的权重序列 :return:选取的值在原列表里的索引def weight_choice(weight): """ t = random.randint(0, sum(weight) - 1) for i, val in enumerate(weight): t -= val if t < 0: return i
- if __name__ == "__main__":
- print(list[weight_choice(num)]) #打印结果 # 例子 print(list[weight_choice([184, 156, 156, 152])])print("抽取时间")print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))) #打印时间
- #......os.system('pause') #暂停
- # coding:utf-8import random #导入随机函数import timeimport os
- bbbzzz第二个程序倒数秒,GUI程序复制代码
- # Countdown using Tkinter
- from tkinter import *
- import time
- import tkinter.messagebox
- class App:
- def __init__(self,master):
- frame = Frame(master)
- frame.pack()
- #self.entryWidget = Entry(frame)
- #self.entryWidget["width"] = 20
- #self.entryWidget.pack(side=LEFT)
- self.hi_there = Button(frame, text="开始计时5分钟", command=self.start)
- self.hi_there.pack(side=LEFT)
- self.hi_there = Button(frame, text="开始计时10分钟", command=self.start2)
- self.hi_there.pack(side=LEFT)
- self.button = Button(frame, text="退出", fg="red", command=frame.quit)
- self.button.pack(side=LEFT)
- def start2(self):
- num = 600
- self.countDown(num)
- def start(self):
- num = 30
- self.countDown(num)
- def countDown(self,seconds):
- lbl1.config(bg='yellow')
- lbl1.config(height=3, font=('times', 110, 'bold'))
- for k in range(seconds, 0, -1):
- if k == 30:
- print("\a")
- if k== 29:
- print("\a")
- if k== 28:
- print("\a")
- lbl1["text"] = k
- root.update()
- time.sleep(1)
- lbl1.config(bg='red')
- lbl1.config(fg='black')
- lbl1["text"] = "时间到!"
- tkMessageBox.showinfo("时间到!","时间到!")
- def GetSource():
- get_window = Tkinter.Toplevel(root)
- get_window.title('Source File?')
- Tkinter.Entry(get_window, width=30,
- textvariable=source).pack()
- Tkinter.Button(get_window, text="Change",
- command=lambda: update_specs()).pack()
- root = Tk()
- root.title("Countdown")
- lbl1 = Label()
- lbl1.pack(fill=BOTH, expand=1)
- app = App(root)
- root.mainloop()
- # Countdown using Tkinter
- 懒散的牛马克一下。 iOS fly ~
- bbbzzz回复2#bbbzzz
改进了窗口最大化和字体巨大复制代码- # Countdown using Tkinter
- from tkinter import *
- import time
- import tkinter.messagebox
- class App:
- def __init__(self,master):
- frame = Frame(master)
- frame.pack()
- self.hi_there = Button(frame, text="开始计时5分钟", command=self.start)
- self.hi_there.pack(side=LEFT)
- self.hi_there = Button(frame, text="开始计时10分钟", command=self.start2)
- self.hi_there.pack(side=LEFT)
- self.button = Button(frame, text="退出", fg="red", command= root.destroy)
- self.button.pack(side=LEFT)
- def start2(self):
- num = 600
- self.countDown(num)
- def start(self):
- num = 300
- self.countDown(num)
- def countDown(self,seconds):
- lbl1.config(bg='yellow')
- lbl1.config(height=1, font=('times', 500, 'bold'))
- for k in range(seconds, 0, -1):
- lbl1["text"] = k
- root.update()
- time.sleep(1)
- lbl1.config(bg='red')
- lbl1.config(fg='black')
- lbl1["text"] = "时间到!"
- def GetSource():
- get_window = Tkinter.Toplevel(root)
- get_window.title('Source File?')
- Tkinter.Entry(get_window, width=30,
- textvariable=source).pack()
- Tkinter.Button(get_window, text="Change",
- command=lambda: update_specs()).pack()
- root = Tk()
- root.attributes("-fullscreen", True)
- root.title("Countdown")
- lbl1 = Label()
- lbl1.pack(fill=BOTH, expand=1)
- app = App(root)
- root.mainloop()
- # Countdown using Tkinter
- wisedan学习下
- bbbzzz#第四个程序
#爬取澳门镜湖医院疫苗及下预约[/code]复制代码- [code]#!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import smtplib
- import pandas as pd
- td=pd.read_html('http://www.kwh.org.mo/',encoding='utf-8')
- tds=str(td)
- if tds.find('有少量貨源提供给首次注射人士')==1:
- a='有货'
- #-------------------发送邮件START
- from email.mime.text import MIMEText
- from email.mime.multipart import MIMEMultipart
- from email.mime.image import MIMEImage
- fromaddr = '[email protected]'#邮件发送方邮箱地址
- password = 'xxxx' #密码(部分邮箱为授权码)
- toaddrs = ['[email protected]','[email protected]']
- message = MIMEText('姓名:xxx \n性别:女 \n证件号:1.身份证:xxx 2.港澳通行证: \n联系电话:xxx \n预约日期:1.2021年4月16日、2.2021年4月19日、3.2021年4月19日\n邮箱:xxx'+a)
- message['Subject'] = 'xxxHPV预约'
- sender = '[email protected]'
- receivers = ['[email protected]','[email protected]','[email protected]']
- #发送方信息
- message['From'] = '[email protected]'
- #接受方信息
- message['To'] = receivers[0]+','+receivers[1]
- #---------------------------------------------------------------------
- #登录并发送邮件
- try:
- server = smtplib.SMTP('smtp.163.com')#163邮箱服务器地址,端口默认为25
- server.login(fromaddr,password)
- server.sendmail(fromaddr, toaddrs, message.as_string())
- print( "邮件发送成功")
- except smtplib.SMTPException as e:
- print('error',e) #打印错误
- #--------------------------发送邮件END
- else:
- a='没货'
- print(a)
- [code]#!/usr/bin/env python
- yandongdiy
- guangjianMark you iOS fly ~