我希望获取多部分表单数据并将其转换为字典。对于 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.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)
关于python - 如何处理 aiohttp 响应中的表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39905588/