试图延迟我的程序的一部分 [英] trying to delay part of my program

查看:49
本文介绍了试图延迟我的程序的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图拍摄我打开的网页的快照,但是我需要延迟代码的第二部分,以便程序有时间打开页面

Im trying to take a snapshot of the webpage i open but i need to delay the second part of the code so that the program has time to open the page

这是代码

import os
import sys
import time
import Image
import ImageGrab


import webbrowser
webbrowser.open_new(input("URL: "))
#Need to delay here

SaveDirectory=r'C:\Documents and Settings\User\My Documents\My Pictures'
ImageEditorPath=r'C:\WINDOWS\system32\mspaint.exe'
img=ImageGrab.grab()
box = (100, 100, 400, 400)
region = img.crop(box)
saveas=os.path.join(SaveDirectory,'ScreenShot_'+'.png')
img.save(saveas)
editorstring='""%s" "%s"'% (ImageEditorPath,saveas) 
os.system(editorstring)

推荐答案

您可以尝试使用time.sleep(seconds)来让程序延迟一段时间.

you can try to use time.sleep(seconds) to let your program delay for a while.

这篇关于试图延迟我的程序的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆