NET中的File.WriteAllBytes()之类的Python方法

有一个.net API以JSON中的字符串形式发送字节数据,我正在使用python API读取它并将其写入文件中。

a = io.BytesIO(b"JVberi0xLjQNJcjIyMjIyMg...")
with open('test.pdf','wb') as g:
    g.write(a.getvalue())

我使用此代码创建了一个文件,但无法打开该文件。 我需要另一种方法。

laonongding 回答:NET中的File.WriteAllBytes()之类的Python方法

而不是使用io.BytesIO使用base64。

import base64
data = "strin data"
base64_data =base64.b64decode(data)
with open(filename,'wb') as f:
    f.write(base64_data)
本文链接:https://www.f2er.com/2928213.html

大家都在问