python3发送请求

pip安装requests

pip install requests

文件代码

#coding:utf-8
import requests
import json

class RequestClass:
    def sendPost(self):
        url="http://xxx.xx.xx..."
        param={"key1":value1,"key2":value2,...}
        r = requests.post(url, data=param)
        jo=json.loads(r.text)
        print(jo["result"])
        return jo["result"]

    def sendGet(self):
        r = requests.get("http://xx....")
        text=r.text
        return text

猜你喜欢

转载自blog.csdn.net/GrassEva/article/details/79984112