圆月山庄资源网 Design By www.vgjia.com

python开启debug模式的代码如下所示:

import requests
 session = requests.session()
import logging
import requests
logging.basicConfig(level=logging.DEBUG,
     format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
     datefmt='%a, %d %b %Y %H:%M:%S',
     filename='myapp.log',
  filemode='w')
logging.debug(session.get('http://www.qq.com'))
logging.debug(session.get('http://www.qq.com'))

运行结果:

Mon, 26 Nov 2018 02:31:08 connectionpool.py[line:205] DEBUG Starting new HTTP connection (1): www.qq.com:80
Mon, 26 Nov 2018 02:31:08 connectionpool.py[line:393] DEBUG http://www.qq.com:80 "GET / HTTP/1.1" 302 168
Mon, 26 Nov 2018 02:31:08 connectionpool.py[line:813] DEBUG Starting new HTTPS connection (1): www.qq.com:443
Mon, 26 Nov 2018 02:31:08 connectionpool.py[line:393] DEBUG https://www.qq.com:443 "GET / HTTP/1.1" 200 None
Mon, 26 Nov 2018 02:31:08 server_t2.py[line:17] DEBUG <Response [200]>
Mon, 26 Nov 2018 02:31:08 connectionpool.py[line:393] DEBUG http://www.qq.com:80 "GET / HTTP/1.1" 302 168
Mon, 26 Nov 2018 02:31:08 connectionpool.py[line:393] DEBUG https://www.qq.com:443 "GET / HTTP/1.1" 200 None
Mon, 26 Nov 2018 02:31:08 server_t2.py[line:18] DEBUG <Response [200]>

用来测试每次请求,看是不是长链接,记录下debug怎么设置。

总结

以上所述是小编给大家介绍的python开启debug模式的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

标签:
python开启debug模式,python,debug模式

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com