利用python實現每x分鍾截屏一次存放到指定文件夾


#創建一個文件夾用來保存文件
#每x分鍾截屏一次存放到指定文件夾
import os
import pyautogui as pa
import time
def make_dir(dirs):

if not os.path.exists(dirs):
os.makedirs(dirs)
#檢測並且創建目錄
def get_file_path(dirs):
time_format = "%a %b %d %H %M %S %Y"
time_now=time.strftime(time_format,time.localtime())
file_path=os.path.join(dirs,time_now)
file_path=file_path+".png"

return file_path
#按照時間獲得截屏名稱


def screen_shot(file_path):
im1 = pa.screenshot(file_path)
#pa.screenshot方法里保存的文件不能是數字開頭,時間間隔之間也不能用:連接

def main():
while True:
time.timesleep=5
#設定間隔時長單位為秒
dirs="E:\local_dirs"
make_dir(dirs)
screen_shot(get_file_path(dirs))

main()


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM