Python 请求测量响应时间
Python requests measure response time
我正在尝试测量网站的响应时间,但出现错误。
脚本:
#!/usr/bin/python
import requests
time= requests.get("http://google.com").elapsed.total_seconds()
print time
错误:
Traceback (most recent call last):
File "./test.py", line 5, in <module>
time= requests.get("http://google.com").elapsed.total_seconds()
AttributeError: 'Response' object has no attribute 'elapsed'
.elapsed
属性是在 requests
1.2.0 (changelog) 中引入的。更新包:
pip install --upgrade requests
我正在尝试测量网站的响应时间,但出现错误。
脚本:
#!/usr/bin/python
import requests
time= requests.get("http://google.com").elapsed.total_seconds()
print time
错误:
Traceback (most recent call last):
File "./test.py", line 5, in <module>
time= requests.get("http://google.com").elapsed.total_seconds()
AttributeError: 'Response' object has no attribute 'elapsed'
.elapsed
属性是在 requests
1.2.0 (changelog) 中引入的。更新包:
pip install --upgrade requests