我如何说如果在特定时间执行代码?

时间:2019-05-28 20:57:07

标签: python python-3.x

我不知道如何说是否在特定时间在if下声明了代码

在Google上的python中查找日期和时间

from time import datetime
import time
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

if (datetime == 16:47):
  email = '*****'
  password = '*****'
  send_to_email = '******'
  subject ='sp'
  message ="go here: bit.ly/amalssite"
  msg = MIMEMultipart()
  msg['From'] = email
  msg['To'] = send_to_email
  msg['Subject'] = subject

  msg.attach(MIMEText(message, 'plain'))

  while True:  
    server = smtplib.SMTP('mail.gmx.com', 587)
    server.starttls()
    server.login(email, password)
    text = msg.as_string()
    server.sendmail(email, send_to_email, text)
    server.quit()

0 个答案:

没有答案