2
の例では、私はファイルのpython 3.5 + aiohttp:TypeError例外:Aバイトのようなオブジェクトが必要な、ない「str」は使用io.BytesIO
with open('test_zip'), 'wb') as f:
f.write(content)
res = requests.post(URL, data={'file': content})
を送る。そして、私は、サーバー側のファイルを取得しよう
async def handle(request):
form = await request.post()
data = io.BytesIO((form['file']))
with open('test_zip_2', 'wb') as file:
file.write(data)
そして、エラー発生しますが、私はあなたがを変換する必要はありませんUbuntuの
data = io.BytesIO((form['file'])) TypeError: a bytes-like object is required, not 'str'
私の推測では、 'form ['file']'は 'str'型です。代わりに 'form ['file']。encode( 'ascii')'を渡すようにしてください。これは文字列のバイト配列を使用するためです。 –