python 异步post请求

2021-08-13 11:16:29 浏览数 (1)

代码语言:javascript复制
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)

0 人点赞