发布时间:2019-08-27 08:14:52编辑:auto阅读(2021)
import os
import time
def fun(name):
write_name="command %s failed!\n" % name
print write_name
f = open('/tmp/cs.log','a')
f.write(write_name)
f.close()
def tary(name):
print "the command is %s" % name
command_id = os.system(name)
while command_id != 0:
fun(name)
time.sleep(10)
command_id = os.system(name)
time.sleep(5)
tary("reboot")
Python 编程中使用 time 模块可以让程序休眠
具体方法是time.sleep(秒数),其中“秒数”以秒为单位,可以是小数,0.1秒则代表休眠100毫秒。
# 例1:循环输出休眠1秒
上一篇: python中unicode 和 str
下一篇: python socket 编程之三:长
50554
49873
40462
37452
31886
28766
27684
22467
22462
20775
560°
1186°
965°
891°
1150°
1007°
1631°
3023°
2744°
2067°