1
我使用了下面的代碼來顯示結果和時間,以找出mod_wsgi.But中的結果watever我試試我總是將經過的時間作爲0,儘管我將時間舍入到了納秒。我現在要做什麼來計算差異?python在mod_wsgi中的時差
#!D:/Python27/python
from wsgiref.simple_server import make_server
from cgi import parse_qs, escape
import time
import datetime
html = """
<html>
<body>
<h2>Sum of first n factorials</h2>
<form method="get" action="Sec1q10.py">
Number :<input type="text" name="t1">
<br> <input type="submit" value="Submit">
</form>
<br>
Result:%s<br>
Now:%s<br>
End:%s<br>
Time:%s
</body>
</html>"""
def application(environ, start_response):
d=parse_qs(environ['QUERY_STRING'])
now = int(round(time.time()*1000000))
n=d.get('t1',[''])[0]
i=1
p=1
s=0
while (i<=int(n)):
p = p*i
s =s+p
i = i+1
end= int(round(time.time()*1000000))
diff=end-now
status = '200 OK'
output = html % (s or 'Empty',now or 'Empty',end or 'Empty',diff or 'Empty')
response_headers = [('Content-type', 'text/html'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
,它顯示輸出,如果我進入了一個號碼4:
Result:33
Now:1346520500489000
End:1346520500489000
Time:Empty
笏我還可以用它來找出過去的時間?