我的java程序员将excel文件转换成二进制文件并将二进制内容发送给我。在
他使用sun.misc.BASE64Encoder
和{
我需要使用python将二进制数据转换为数据帧。在
数据看起来像
UEsDBBQABgAIAAAAIQBi7p1oXgEAAJAEAAATAAgCW0NvbnRlbnRfVHl........
我试过bas64
解码器,但没用。在
我的代码:
import base64
with open('encoded_data.txt','rb') as d:
data=d.read()
print(data)
`UEsDBBQABgAIAAAAIQBi7p1oXgEAAJAEAAATAAgCW0NvbnRlbnRfVHl........`
decrypted=base64.b64decode(data)
print(decrypt)
'PK\x03\x04\x14\x00\x06\x00\x08\x00\x00\x00!\x00b\xee\x9dh^\x01\x00\x00\x90\x04\x00\x00\x13\x00\x08\x02[Content_Types].xml \xa2\x04\x02(\xa0\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
请帮我把这个二进制数据转换成熊猫数据帧。在
你快到了。既然解密对象是字节字符串,为什么不使用
BytesIO
?在从您的评论中回答您的问题:如何将df转换为二进制编码的对象?在
好吧,如果你想把它转换回b64编码的对象,熊猫把它转换成excel,那么:
^{pr2}$要将编码对象写入文件(只需关闭循环:p):
您也可以使用openpyxl模块 这是修改后的代码
相关问题 更多 >
编程相关推荐