编程语言
首页 > 编程语言> > python 异步post请求

python 异步post请求

作者:互联网

import aiohttp

 headers = {'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 6.0.1; Nexus 5 Build/MMB29K) tuhuAndroid 5.24.6',
                   'content-type': 'application/json'}
        async with aiohttp.ClientSession(headers=headers) as sess:
            url = "你的接口"
            data_json = json.dumps({"msg": message_dict})
            async with sess.post(url, data=data_json) as data:
                print(data)

  

标签:异步,sess,aiohttp,python,headers,json,post,data
来源: https://www.cnblogs.com/wuyongcong/p/15126808.html