简单实现DD自动打卡并发送通知邮件

环境准备

Windows操作系统+adbshell1.0.40+pyhon3.7+visual stdio code stable+android手机+数据线,并配置环境变量
在这里插入图片描述

打卡程序

需要定位屏幕坐标

import os
import time

a0=os.popen("adb shell input keyevent 26")
##b=a0.read()
##print(b)
time.sleep(5)     ##等待5秒
a1=os.popen("adb shell input swipe 767 1500 767 500")
time.sleep(5)
a2=os.popen("adb shell input tap 632 1605")
time.sleep(5)
a3=os.popen("adb shell input tap 330 610")
time.sleep(5)
a4=os.popen("adb shell input text xxxx")     ##DD密码
time.sleep(5)
a5=os.popen("adb shell input tap 945 752")
time.sleep(5)
a6=os.popen("adb shell input tap 783 1980")
time.sleep(5)
a7=os.popen("adb shell input tap 100 1017")
time.sleep(5)
a8=os.popen("adb shell input tap 770 630")
time.sleep(5)
a9=os.popen("adb shell input tap 801 1408")
time.sleep(5)
a10=os.popen("adb shell screencap -p /sdcard/1.png")   ##截图
time.sleep(5)

## ****3.发送邮件程序****
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
import time

my_date=time.strftime('%m-%d',time.localtime(time.time()))         ##格式化本地日期、时分秒
my_time=time.strftime('%H:%M:%S',time.localtime(time.time()))
my_timestamp=my_date+' '+my_time

my_sender='xxxxx'    ##发送账号
my_pass = 'xxxxxx'          ##邮箱密码    
my_user='xxxx'     ##接收账号
def mail():                              ##定义邮件函数,结果初始为成功,若try下面有一个执行失败,就返回失败结果
    result=True
    try:
        
        ##msg=MIMEText(my_content,'html','utf-8')      ##html格式邮件,测试时用了一下
        ##msg=MIMEMultipart('related')                 ##带附件邮件,测试时用了一下
        msg=MIMEMultipart()                 ##多个附件模式
        msg['From']=formataddr(["xxx",my_sender])      ##发送人代称及账户
        msg['To']=formataddr(["xxx",my_user])     ##发送人代称及账户
        msg['Subject']="dingdingdaka"    ##标题

        ##msgAlternative = MIMEMultipart('alternative')
        ##msg.attach(msgAlternative)
        msg.attach(MIMEText(my_timestamp, 'plain', 'utf-8'))    ##正文,写时间

        my_att1=MIMEText(open('1.png', 'rb').read(), 'base64', 'utf-8')         ##通过open函数打开截图并读取,若没有截图会正常关闭
        my_att1["Content-Type"] = 'application/octet-stream'      ##流模式
        my_att1["Content-Disposition"] = 'attachment; filename="1.png"'     ##附件名称

        msg.attach(my_att1)

 
        server=smtplib.SMTP_SSL("smtp.qq.com", 465)     ##smtp服务器
        server.login(my_sender, my_pass)
        server.sendmail(my_sender,[my_user,],msg.as_string())
        server.quit()
    except Exception: 
        result=False
    return result
    
my_result=mail()
if my_result:
    print("success")
else:
    print("fail")

定时任务

在任务计划程序添加任务,python xxx.py
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DDPM(Diffusion Probabilistic Models)是一种生成模型,用于对数据进行建模和生成。Python可以使用深度学习框架来实现DDPM,例如PyTorch。 下面是一种可能的Python实现DDPM的步骤: 1. 导入所需的库和模块: ```python import torch import torch.nn as nn import torch.optim as optim ``` 2. 定义DDPM模型的网络结构: ```python class DDPM(nn.Module): def __init__(self, input_dim, hidden_dim, output_dim): super(DDPM, self).__init__() self.fc1 = nn.Linear(input_dim, hidden_dim) self.fc2 = nn.Linear(hidden_dim, hidden_dim) self.fc3 = nn.Linear(hidden_dim, output_dim) def forward(self, x): x = torch.relu(self.fc1(x)) x = torch.relu(self.fc2(x)) x = self.fc3(x) return x ``` 3. 定义训练函数: ```python def train(model, data, num_epochs, learning_rate): criterion = nn.MSELoss() optimizer = optim.Adam(model.parameters(), lr=learning_rate) for epoch in range(num_epochs): optimizer.zero_grad() output = model(data) loss = criterion(output, data) loss.backward() optimizer.step() if (epoch+1) % 10 == 0: print('Epoch [{}/{}], Loss: {:.4f}'.format(epoch+1, num_epochs, loss.item())) ``` 4. 准备数据并进行训练: ```python # 假设数据已经准备好,存储在data变量中 input_dim = data.shape hidden_dim = 64 output_dim = input_dim model = DDPM(input_dim, hidden_dim, output_dim) num_epochs = 100 learning_rate = 0.001 train(model, data, num_epochs, learning_rate) ``` 这是一个简单的示例,实际上DDPM的实现可能更加复杂,需要根据具体的问题和数据进行调整和优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值