不解釋,直接上程式碼:
<span style="color: #008080"> 1</span> <span style="color: #008000">#</span><span style="color: #008000">!/usr/bin/env python </span> <span style="color: #008080"> 2</span> <span style="color: #008000">#</span><span style="color: #008000"> -*- encoding: utf-8 -*-</span> <span style="color: #008080"> 3</span> <span style="color: #008080"> 4</span> <span style="color: #800000">"""</span> <span style="color: #008080"> 5</span> <span style="color: #800000">@version: v1.0 </span><span style="color: #008080"> 6</span> <span style="color: #800000">@author: elijahxb </span><span style="color: #008080"> 7</span> <span style="color: #800000">@OS: linux </span><span style="color: #008080"> 8</span> <span style="color: #800000">@contact: elijahxb@163.com </span><span style="color: #008080"> 9</span> <span style="color: #800000">@site: </span><span style="color: #008080">10</span> <span style="color: #800000">@software: PyCharm Community Edition </span><span style="color: #008080">11</span> <span style="color: #800000">@file: zhangye.py </span><span style="color: #008080">12</span> <span style="color: #800000">@time: 17-7-2 下午12:16 </span><span style="color: #008080">13</span> <span style="color: #800000">"""</span> <span style="color: #008080">14</span> <span style="color: #008080">15</span> <span style="color: #800000">'''</span> <span style="color: #008080">16</span> <span style="color: #800000">本次登录测试: </span><span style="color: #008080">17</span> <span style="color: #800000">USERNAME:test001_001 </span><span style="color: #008080">18</span> <span style="color: #800000">PASSWORD:test001 </span><span style="color: #008080">19</span> <span style="color: #800000">URL: </span><span style="color: #008080">20</span> <span style="color: #800000">TYPE: POST </span><span style="color: #008080">21</span> <span style="color: #800000">HOST: www.zhangye.ccoo.cn </span><span style="color: #008080">22</span> <span style="color: #800000">POSTURL: </span><span style="color: #008080">23</span> <span style="color: #800000">POSTDATA:username=test001_001&password=test001 </span><span style="color: #008080">24</span> <span style="color: #800000">'''</span> <span style="color: #008080">25</span> <span style="color: #0000ff">import</span><span style="color: #000000"> httplib </span><span style="color: #008080">26</span> <span style="color: #0000ff">import</span><span style="color: #000000"> urllib </span><span style="color: #008080">27</span> <span style="color: #008080">28</span> HOST = <span style="color: #800000">'</span><span style="color: #800000">182.92.232.234</span><span style="color: #800000">'</span> <span style="color: #008080">29</span> SOURCEURL = <span style="color: #800000">"</span><span style="color: #800000"></span><span style="color: #800000">"</span> <span style="color: #008080">30</span> POSTURL = <span style="color: #800000">'</span><span style="color: #800000"></span><span style="color: #800000">'</span> <span style="color: #008080">31</span> PORT = 80 <span style="color: #008080">32</span> STRICT = False <span style="color: #008000">#</span><span style="color: #008000"> 默认False,表示无法解析服务器返回的状态行时,是否抛出BadStatusLine异常</span> <span style="color: #008080">33</span> TIMEOUT = 5 <span style="color: #008080">34</span> HEADERS =<span style="color: #000000"> { </span><span style="color: #008080">35</span> <span style="color: #800000">'</span><span style="color: #800000">Content-type</span><span style="color: #800000">'</span>: <span style="color: #800000">'</span><span style="color: #800000">application/x-www-form-urlencoded</span><span style="color: #800000">'</span><span style="color: #000000">, </span><span style="color: #008080">36</span> <span style="color: #800000">"</span><span style="color: #800000">Accept</span><span style="color: #800000">"</span>: <span style="color: #800000">"</span><span style="color: #800000">*/*</span><span style="color: #800000">"</span> <span style="color: #008080">37</span> <span style="color: #000000">} </span><span style="color: #008080">38</span> TestDATA =<span style="color: #000000"> { </span><span style="color: #008080">39</span> <span style="color: #800000">'</span><span style="color: #800000">username</span><span style="color: #800000">'</span>: <span style="color: #800000">'</span><span style="color: #800000">test001_001</span><span style="color: #800000">'</span><span style="color: #000000">, </span><span style="color: #008080">40</span> <span style="color: #800000">'</span><span style="color: #800000">password</span><span style="color: #800000">'</span>: <span style="color: #800000">'</span><span style="color: #800000">test001</span><span style="color: #800000">'</span> <span style="color: #008080">41</span> <span style="color: #000000">} </span><span style="color: #008080">42</span> TestDATA =<span style="color: #000000"> urllib.urlencode(TestDATA) </span><span style="color: #008080">43</span> <span style="color: #008080">44</span> <span style="color: #0000ff">try</span><span style="color: #000000">: </span><span style="color: #008080">45</span> <span style="color: #008000">#</span><span style="color: #008000"> Conn = httplib.HTTPConnection(HOST, PORT, STRICT, TIMEOUT, SOURCEURL)</span> <span style="color: #008080">46</span> HttpClient =<span style="color: #000000"> httplib.HTTPConnection(HOST) </span><span style="color: #008080">47</span> HttpClient.request(<span style="color: #800000">'</span><span style="color: #800000">POST</span><span style="color: #800000">'</span><span style="color: #000000">, POSTURL, TestDATA, HEADERS) </span><span style="color: #008080">48</span> <span style="color: #008080">49</span> response =<span style="color: #000000"> HttpClient.getresponse() </span><span style="color: #008080">50</span> <span style="color: #0000ff">print</span><span style="color: #000000"> response.status </span><span style="color: #008080">51</span> <span style="color: #0000ff">print</span><span style="color: #000000"> response.reason </span><span style="color: #008080">52</span> <span style="color: #0000ff">print</span><span style="color: #000000"> response.read() </span><span style="color: #008080">53</span> <span style="color: #0000ff">print</span><span style="color: #000000"> response.getheaders() </span><span style="color: #008080">54</span> <span style="color: #0000ff">except</span><span style="color: #000000"> Exception, e: </span><span style="color: #008080">55</span> <span style="color: #0000ff">print</span><span style="color: #000000"> e </span><span style="color: #008080">56</span> <span style="color: #0000ff">finally</span><span style="color: #000000">: </span><span style="color: #008080">57</span> <span style="color: #0000ff">if</span><span style="color: #000000"> HttpClient: </span><span style="color: #008080">58</span> HttpClient.close()
以上是Python之POST登入測試的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Arraysinpython,尤其是Vianumpy,ArecrucialInsCientificComputingfortheireftheireffertheireffertheirefferthe.1)Heasuedfornumerericalicerationalation,dataAnalysis和Machinelearning.2)Numpy'Simpy'Simpy'simplementIncressionSressirestrionsfasteroperoperoperationspasterationspasterationspasterationspasterationspasterationsthanpythonlists.3)inthanypythonlists.3)andAreseNableAblequick

你可以通過使用pyenv、venv和Anaconda來管理不同的Python版本。 1)使用pyenv管理多個Python版本:安裝pyenv,設置全局和本地版本。 2)使用venv創建虛擬環境以隔離項目依賴。 3)使用Anaconda管理數據科學項目中的Python版本。 4)保留系統Python用於系統級任務。通過這些工具和策略,你可以有效地管理不同版本的Python,確保項目順利運行。

numpyarrayshaveseveraladagesoverandastardandpythonarrays:1)基於基於duetoc的iMplation,2)2)他們的aremoremoremorymorymoremorymoremorymoremorymoremoremory,尤其是WithlargedAtasets和3)效率化,效率化,矢量化函數函數函數函數構成和穩定性構成和穩定性的操作,製造

數組的同質性對性能的影響是雙重的:1)同質性允許編譯器優化內存訪問,提高性能;2)但限制了類型多樣性,可能導致效率低下。總之,選擇合適的數據結構至關重要。

到CraftCraftExecutablePythcripts,lollow TheSebestPractices:1)Addashebangline(#!/usr/usr/bin/envpython3)tomakethescriptexecutable.2)setpermissionswithchmodwithchmod xyour_script.3)

numpyArraysareAreBetterFornumericalialoperations andmulti-demensionaldata,而learthearrayModuleSutableforbasic,內存效率段

numpyArraySareAreBetterForHeAvyNumericalComputing,而lelethearRayModulesiutable-usemoblemory-connerage-inderabledsswithSimpleDatateTypes.1)NumpyArsofferVerverVerverVerverVersAtility andPerformanceForlargedForlargedAtatasetSetsAtsAndAtasEndCompleXoper.2)

ctypesallowscreatingingangandmanipulatingc-stylarraysinpython.1)usectypestoInterfacewithClibrariesForperfermance.2)createc-stylec-stylec-stylarraysfornumericalcomputations.3)passarraystocfunctions foreforfunctionsforeffortions.however.however,However,HoweverofiousofmemoryManageManiverage,Pressiveo,Pressivero


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版
中文版,非常好用

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Atom編輯器mac版下載
最受歡迎的的開源編輯器