Python 如何处理aiohttp响应中的表单数据
我希望获得多部分表单数据并将其转换为字典。对于json来说很简单,但这似乎有点不同 当前代码:Python 如何处理aiohttp响应中的表单数据,python,multipartform-data,python-3.5,aiohttp,Python,Multipartform Data,Python 3.5,Aiohttp,我希望获得多部分表单数据并将其转换为字典。对于json来说很简单,但这似乎有点不同 当前代码: app = web.Application() async def deploy(request): # retrieve multipart form data or # x-www-form-urlencoded data # convert to a dictionary if not already text = "Hello" return web.
app = web.Application()
async def deploy(request):
# retrieve multipart form data or
# x-www-form-urlencoded data
# convert to a dictionary if not already
text = "Hello"
return web.Response(text=text)
app.router.add_post('/', deploy)
web.run_app(app)
您可以使用
request.post()
方法
app = web.Application()
async def deploy(request):
# retrieve multipart form data or
# x-www-form-urlencoded data
data = await request.post()
print(data)
text = "Hello"
return web.Response(text=text)
app.router.add_post('/', deploy)
web.run_app(app)
令人惊叹的aiohttp的文档在示例上有点单薄。我希望这对将来的人有所帮助。