python实现截取屏幕保存文件,删除N天前截图的例子
作者:woobol 时间:2021-09-19 18:13:49
我就废话不多说,直接上代码吧!
from PIL import ImageGrab
import time
import schedule
import os
import shutil
import datetime
days = -3
# 截屏
def savepic():
im = ImageGrab.grab()
now = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())
day = time.strftime("%Y%m%d", time.localtime())
file_path_top = 'c:\\tmp\\'
if not os.path.exists(file_path_top):
os.mkdir(file_path_top)
file_path = 'c:\\tmp\\'+day+'\\'
if not os.path.exists(file_path):
os.mkdir(file_path)
im.save(file_path+now+'.jpg')
# 删除文件
def deletefile():
today = datetime.datetime.now()
offset = datetime.timedelta(days=days)
re_date = today + offset
file_dir = r'C:\tmp'
for root, dirs, files in os.walk(file_dir):
for i in dirs:
if(i<=re_date.strftime('%Y%m%d')):
path = 'C:\\tmp\\'+i
if (os.path.exists(path)):
shutil.rmtree(path)
schedule.every(60).seconds.do(savepic)
schedule.every().day.at("00:30").do(deletefile)
while True:
schedule.run_pending()
time.sleep(1)
来源:https://blog.csdn.net/weixin_42188827/article/details/89311199
标签:python,截取,屏幕,保存
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python中音频处理库pydub的使用教程
2023-07-15 20:22:54
Go标准容器之Ring的使用说明
2023-09-21 02:18:14
怎样在MySQL数据库中导出整个数据库
2008-12-31 15:13:00
两个非常规ASP木马(可躲过扫描)
2011-03-11 10:38:00
asp日期转换成汉字格式程序
2008-07-08 18:19:00
MySQL权限分配
2011-01-29 16:37:00
修改新云CMS底部版权信息字数限制
2008-07-31 18:00:00
![](https://img.aspxhome.com/file/UploadPic/20087/31/200873118219668s.gif)
10个提高网站可用性的实用技巧[译]
2009-06-12 12:37:00
![](https://img.aspxhome.com/file/UploadPic/20096/12/e110ff69d4158da954232063c6e0f6d7-48s.jpeg)
mysql 获取表有多少列
2010-10-14 13:44:00
Go语言编程中字符串切割方法小结
2023-06-16 01:41:24
8行代码实现Python文件去重
2023-11-20 14:47:35
![](https://img.aspxhome.com/file/2023/4/64334_0s.jpg)
JS将指定的某个字符全部转换为其他字符实例代码
2023-08-28 21:01:01
![](https://img.aspxhome.com/file/2023/3/56153_0s.png)
跨浏览器的本地存储(二):DOM:Storage
2008-08-15 13:39:00
SQL Server 2005 五个动态管理对象
2008-12-18 14:50:00
FSO读取BMP,JPG,PNG,GIF图像文件信息的函数
2007-08-04 09:56:00
CSS解决未知高度的垂直水平居中自适应问题
2009-03-17 17:06:00
5个常见的XHTML验证错误
2010-01-15 20:24:00
![](https://img.aspxhome.com/file/UploadPic/20101/15/200px-xhtml-23s.png)
python实现上传样本到virustotal并查询扫描信息的方法
2023-06-30 19:59:45
pytorch训练神经网络爆内存的解决方案
2023-07-06 01:46:24
![](https://img.aspxhome.com/file/2023/2/62292_0s.png)
asp中提取HTML中图片的SRC路径
2008-10-24 08:42:00