バイナリを埋め込む便利な方法xml
は、base64 エンコードです。XAML
これは、たとえば小さな画像を送信するために使用するアプローチです。コードのどこかで次のようにすることができます。
import base64
img = open('some.png',rb').read()
base64.b64encode(img)
# append it to your buffer
そして反対側では:
#get the img portion in the buffer
import base64
img = base64.b64decode(fetched_img)
# write it to disk or whatever
これは、内のバイナリ ファイルを処理する標準/通常のXML
方法です。
使用base64
は非常に簡単です。これはインタープリターの例です。
In [1]: import base64
In [4]: base64.b64encode('example')
Out[4]: 'ZXhhbXBsZQ=='
In [5]: base64.b64decode('ZXhhbXBsZQ==')
Out[5]: 'example'
ここでドキュメントを読むことができます。
お役に立てれば!