python+requests進行get、post方法接口測試

簡介:Requests 是用Python語言編寫,基於 urllib,採用 Apache2 Licensed 開源協議的 HTTP 庫。它比 urllib 更加方便,能夠節約咱們大量的工做,徹底知足 HTTP 測試需求。Requests 的哲學是以 PEP 20 的習語爲中心開發的,因此它比 urllib 更加 Pythoner。python

1、請求方法類型

一、get請求:requests.get(‘url‘)
二、post請求:requests.post(「url/post」)
三、put請求:requests.put(「url/put」)
四、delete請求:requests.delete(「url/delete」)
五、head請求:requests.head(「url/get」)
六、options請求:requests.options(「url/get」)等json

今天咱們來說解如何進行get、post方法的接口測試。api

2、get請求

首先引用requests庫和json庫,由於咱們使用的是requests進行接口測試的。ide

python+requests進行get、post方法接口測試

查看一下結果工具

python+requests進行get、post方法接口測試

3、post請求

post請求和get請求不一樣的地方在於post請求須要傳遞body參數post

python+requests進行get、post方法接口測試

這就是python實現get、post接口請求的方法測試

也可使用工具進行接口測試,好比國產的接口測試工具apiposturl

使用apipost進行get請求blog

python+requests進行get、post方法接口測試

進行post請求接口

python+requests進行get、post方法接口測試

還能夠生成各類格式的接口文檔好比:word格式的接口文檔

python+requests進行get、post方法接口測試

國產接口工具apipost下載地址:https://www.apipost.cn

相關文章
相關標籤/搜索