六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 54|回复: 0

Python截屏程序

[复制链接]

升级  54.33%

111

主题

111

主题

111

主题

举人

Rank: 3Rank: 3

积分
363
 楼主| 发表于 2013-1-15 02:34:17 | 显示全部楼层 |阅读模式
说明:必须安装PIL库

# -*- coding:UTF-8 -*-'''Created on 2010-5-6@author: shiyong'''import osfrom PIL import ImageGrabimport timeclass Capturer(object):        '''截屏程序'''        def capture(self,path='C:\\images'):        '''                    截屏并保存图片至path目录下        '''        if not os.path.isdir(path) or not os.path.exists(path):            os.makedirs(path)        cutime = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))        filename = path+'\\'+cutime+'.gif'        im = ImageGrab.grab()        im.save(filename)if __name__ == '__main__':        cer = Capturer()    while True:        time.sleep(2)        cer.capture()
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表