小编lee*_*lee的帖子

如何aiohttp请求post文件列表python请求模块?

我想使用 aiohttp 进行多帖子。而且,我需要用文件发布。但是,我的代码不起作用这是我的代码

import aiohttp

file = open('file/path', 'rb')
async with aiohttp.request('post', url, files=file) as response:
   return await response.text()
Run Code Online (Sandbox Code Playgroud)

和request.FILES is None

这是引用通告

    def post(self, url: StrOrURL,
             *, data: Any=None, **kwargs: Any) -> '_RequestContextManager':
        """Perform HTTP POST request."""
        return _RequestContextManager(
            self._request(hdrs.METH_POST, url,
                          data=data,
>                         **kwargs))
E       TypeError: _request() got an unexpected keyword argument 'files'

Run Code Online (Sandbox Code Playgroud)

拜托....这可能...?我需要解决方案...请...T^T

这是所需的输出

request.FILES['key'] == file

关键是html形式

    def post(self, url: StrOrURL,
             *, data: Any=None, **kwargs: Any) -> '_RequestContextManager':
        """Perform HTTP POST request."""
        return _RequestContextManager(
            self._request(hdrs.METH_POST, url, …
Run Code Online (Sandbox Code Playgroud)

python python-asyncio aiohttp

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

aiohttp ×1

python ×1

python-asyncio ×1