从零开始学习--Python-定时执行 7月2日

Python

                                                                                                                     ---小白121的记录笔记


import time
import datetime 


def print_dadada(): #执行打印"hello wrold"
    print('hello world')


def texting(hour = 0, minute = 0): #每天 0 点 0 分执行 
    while True:
        while True:
            a = datetime.datetime.now() #获取当前时间
            if a.hour == hour and a.minute == minute: #如果等于 0点 0分 则退出循环
                break
            time.sleep(29) #暂停29s

        print_dadada() #执行打印任务
        time.sleep(60) #暂停 60 s


texting() #执行脚本

                                                                                                                                        ---源自 董付国的Python专栏

单词:

texting    检测

opera    歌剧

session    会话

press    按

confirm    确认

contact    接触

message    信息

percent    百分比

loading   正在加载

may    可以


猜你喜欢

转载自blog.csdn.net/qq_42184699/article/details/80890348
今日推荐