我在MongoDB存储用户简历中有一个集合,它们存储为:

我尝试使用python将其与此post进行转换,但生成的文件不能被视为pdf文件。
python代码有:
import base64, os
from pymongo import *
client = MongoClient("mongodb://localhost:27017/")
db = client.local
collection = db.users
ppl = collection.find({
"_id": "38M8GoJS57Tp9MsGM"
})[0]
bindata = ppl["profile"]["resume"]
with open(os.path.expanduser('~/Desktop/test.pdf'), 'wb') as fout:
fout.write(base64.decodestring(bindata))我想知道我该怎么做。
发布于 2017-10-22 23:06:22
我通过直接改变
fout.write(base64.decodestring(bindata))至
fout.write(bindata)因为二进制数据可以直接写入
https://stackoverflow.com/questions/46308142
复制相似问题