python3 中调用post和get接口调用的很实用的例子

用了很多方法都没有这个实用


POST API接口:

import json
import requests
if __name__ == '__main__':
    url = "http://127.0.0.1:9001/rsa/set_uplod"
    headers = {'content-type': 'application/json'}
    requestData = {"certificate_no": "56565656565656", "auth_code": "123456"}
    ret = requests.post(url, json=requestData, headers=headers)
    if ret.status_code == 200:
        text = json.loads(ret.text)
        print(text)

get  API 接口:

import json
import requests

if __name__ == '__main__':

    url = "http://127.0.0.1:9001/getSha1Test?message=APP000051527151133935949D49FDC0A86605313931B9BB9A4C87"
    ret = requests.get(url)
    if ret.status_code == 200:
        text = json.loads(ret.text)
        print(text)

你可能感兴趣的:(开发相关)