Not explained, directly on the code:
1 #!/usr/bin/env python2 #-*-encoding:utf-8-*-3 4 """ 5 @version: v1.06 @author: Elijahxb7 @OS: Linux8 @contact: elijahxb@163.com9 @site:Ten @software: pycharm Community Edition One @file: zhangye.py A @time: 17-7-2 pm 12:16 - """ - the ''' - This login test: - username:test001_001 - password:test001 + URL: - Type:post + HOST:www.zhangye.ccoo.cn A PostURL: at postdata:username=test001_001&password=test001 - ''' - ImportHttplib - ImportUrllib - -HOST ='182.92.232.234' insourceURL ="" -PostURL ='' toPORT = 80 +STRICT = False#default False, indicating whether the Badstatusline exception is thrown when the state row returned by the server cannot be resolved -TIMEOUT = 5 theHEADERS = { * 'Content-type':'application/x-www-form-urlencoded', $ "Accept":"*/*"Panax Notoginseng } -TestDATA = { the 'username':'test001_001', + 'Password':'test001' A } theTestDATA =Urllib.urlencode (TestDATA) + - Try: $ #Conn = Httplib. Httpconnection (HOST, PORT, STRICT, TIMEOUT, sourceURL) $HttpClient =Httplib. Httpconnection (HOST) -Httpclient.request ('POST', PostURL, TestDATA, HEADERS) - theResponse =Httpclient.getresponse () - PrintResponse.StatusWuyi PrintResponse.reason the PrintResponse.read () - Printresponse.getheaders () Wu exceptException, E: - Printe About finally: $ ifHttpClient: -Httpclient.close ()