time1 = datetime.now();
time1 -= time1;
time2 = datetime.now();
time2 -= time2;
这就是我尝试将日期时间定义为零的方式。正确的方法是什么?
这就是我想要做的:
import urllib2
from datetime import datetime
time1 = datetime.now();
time1 -= time1;
time2 = datetime.now();
time2 -= time2;
for i in range(0, 5):
x = datetime.now()
response = urllib2.urlopen("http://www.google.com")
time1 += datetime.now() - x
x = datetime.now()
response = urllib2.urlopen("http://facebook.com")
time2 += datetime.now() - x
print time1
print time2
它有效,但我认为这样做是错误的。