热线电话:13121318867

登录
2019-03-22 阅读量: 445
python如何设定在指定的时间内执行程序

sleep(): - 此函数用于在参数中指定的时间内执行程序,括号内参数为指定的时间(秒)。

# Python code to demonstrate the working of

# sleep()

# importing "time" module for time operations

import time

# using ctime() to show present time

print ("Start Execution : ",end="")

print (time.ctime())

# using sleep() to hault execution

time.sleep(4)

# using ctime() to show present time

print ("Stop Execution : ",end="")

print (time.ctime())

输出:

Start Execution : Tue Aug  2 07:59:03 2016
Stop Execution : Tue Aug 2 07:59:07 2016
0.0000
4
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子