私はjsonオブジェクトのワイヤーでイメージを渡そうとしています。 {image: "b'stuff '"}または必要な形式。base64 bytesstringをPythonでバイトストリングに再度文字列に変換するには?
が、私は物事の多様性を試みたと私は問題を得続ける:
ファイル "/usr/lib/python3.5/base64.py"、ライン521、_input_type_check 昇給の例外TypeError中(MSG) TypeError例外ERRから:予想されるバイトのようなオブジェクト、
をstrがない行動はこれを以下のため、これは簡単に複製されます:
np.zeros((32,32,3), dtype=np.uint8)
encoded = base64.encodebytes(image)
encoded = str(encoded) #this happens when you send via json
decoded = base64.decodebytes(encoded)
d_image = np.fromstring(decoded, dtype=np.uint8)
d_image = np.reshape(d_image, (32, 32, 3))
が正しく文字列をデコードするかにそれを取得する方法上の任意の詳細があります数の少ない配列?私はそれが私の人生のために働くように思えません。
甘いです。チャートのように機能します。 –