python用schedule模块实现定时任务
1 import schedule
2 import time
3
4 def test():
5 print("I'm working...")
6 def test2():
7 print("I'm working... in job2")
8
9 # 每10分钟执行一次job函数
10 schedule.every(10).minutes.do(test)
11 # 每10秒执行一次job函数
12 schedule.every(10).seconds.do(test)
13 # 当every()没参数时默认是1小时/分钟/秒执行一次job函数
14 schedule.every().hour.do(test)
15 schedule.every().day.at("10:30").do(test)
16 schedule.every().monday.do(test)
17 # 具体某一天某个时刻执行一次job函数
18 schedule.every().wednesday.at("13:15").do(test)
19 # 可以同时定时执行多个任务,但是每个任务是按顺序执行
20 schedule.every(10).seconds.do(job2)
21 # 如果job函数有有参数时,这么写
22 schedule.every(10).seconds.do(job,"参数")
23 while True:
24 # 启动服务
25 schedule.run_pending()
26 time.sleep(1)
python用schedule模块实现定时任务的更多相关文章
- python中schedule模块的简单使用 || importlib.import_module动态导入模块
1 import schedule 2 import time 3 4 def start(): #定义一个函数 5 print("****") 6 7 8 if __name__ ...
- Python3.6 Schedule模块定时任务
本文使用Python的Schedule模块.Python访问数据库的框架SQLAIchemy 实现了一个:周期性读取mysql 数据的小示例. 一,编程环境 PyCharm2016,Anaconda3 ...
- python的库有多少个?python有多少个模块?
这里列举了大概500个左右的库: ! Chardet字符编码探测器,可以自动检测文本.网页.xml的编码. colorama主要用来给文本添加各种颜色,并且非常简单易用. Prettytable主 ...
- python之platform模块
python之platform模块 ^_^第三个模块从天而降喽!! 函数列表 platform.system() 获取操作系统类型,windows.linux等 platform.platform() ...
- python之OS模块详解
python之OS模块详解 ^_^,步入第二个模块世界----->OS 常见函数列表 os.sep:取代操作系统特定的路径分隔符 os.name:指示你正在使用的工作平台.比如对于Windows ...
- python之sys模块详解
python之sys模块详解 sys模块功能多,我们这里介绍一些比较实用的功能,相信你会喜欢的,和我一起走进python的模块吧! sys模块的常见函数列表 sys.argv: 实现从程序外部向程序传 ...
- 学习PYTHON之路, DAY 6 - PYTHON 基础 6 (模块)
一 安装,导入模块 安装: pip3 install 模块名称 导入: import module from module.xx.xx import xx from module.xx.xx impo ...
- linux下python调用c模块
在C调用Python模块时需要初始化Python解释器,导入模块等,但Python调用C模块却比较简单,下面还是以helloWorld.c 和 main.py 做一说明: (1)编写C代码,hel ...
- Python学习之模块进程函数详解
今天在看<Beginning Linux Programming>中的进程相关部分,讲到Linux几个进程相关的系统函数: system , exec , fork ,wait . Pyt ...
随机推荐
- rds下载备份集
python版本[testuser@localhost tmp]$ python -VPython 2.7.5 需要提前安装RDS[root@localhost ~]# yum -y install ...
- 基本数据类型大总结(int,str,list,dict,tuple)
python基本数据类型 int==>整数,主要用来进行数学运算 str==>字符串,可以保存单一数值 bool==>判断真假,true,false list==>存储大量数据 ...
- HBase scan setBatch和setCaching的区别
HBase的查询实现只提供两种方式: 1.按指定RowKey获取唯一一条记录,get方法(org.apache.hadoop.hbase.client.Get) 2.按指定的条件获取一批记录,scan ...
- vivado 创建PS工程
前言 本文简要介绍在vivado中创建PS工程.单纯使用zynq芯片的PS部分就像使用普通ARM芯片一样,只是多了建立Zynq硬件系统这一个步骤.vivado创建PL工程参见此处 新建工程 与viva ...
- 本地构建:Gulp
Gulp中文网:https://www.gulpjs.com.cn/ Gulp英文网:https://gulpjs.com/ Gulp:工作流程自动化+强化 (一)安装初始化 (二)基础API及插件 ...
- Codeforces Round #FF (Div. 2) D. DZY Loves Modification 优先队列
D. DZY Loves Modification time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- C#---装箱、拆箱的一个案例
using System; namespace ConsoleApplication1 { interface IInterface { void Add(int num); } struct Tes ...
- English trip EM2-LP-4B At school Teacher:Will
课上内容(Lesson) 词汇(Key Word ) art 美术:艺术 business 商科 engineering 工程学 graphic design 平面造型学 history 历 ...
- 『Python CoolBook』Cython_高效数组操作
数组运算加速是至关科学计算重要的领域,本节我们以一个简单函数为例,使用C语言为python数组加速. 一.Cython 本函数为一维数组修剪最大最小值 version1 @cython.boundsc ...
- Petrozavodsk Winter Camp, Andrew, 2014, Bipartite Bicolored Graphs
由i个点和j个点组成的二分图个数为 $3^{ij}$,减去不联通的部分得到得到由i,j个点组成的联通二分图个数 $g_{i,j} = 3_{ij} - \sum_{k=1}^i \sum_{l=0}^ ...