循环执行逻辑
#-*- coding: UTF-8 -*-
import time
import urllib2 def task(i):
urlstr='http://baidu.com'
html = urllib2.urlopen(urlstr,timeout=30).read()
# -*- coding: UTF-8 -*-
print '第',str(i),'次' def tasking(j):
urlstr = 'http://baidu.com'
html = urllib2.urlopen(urlstr,timeout=30).read()
print '第',str(j),'次' def timer(n):
i=0;
j=0;
while True:
print time.strftime('%Y-%m-%d %X', time.localtime())
i+=1
j+=1
task(i)
tasking(j)
time.sleep(n) if __name__ == '__main__':
timer(300)