我正在与Python一起使用Dropbox。我在Dropbox上没有问题,我让所有的认证步骤都没有问题。
当我使用这个代码时:
pdf_dropbox = client.get_file('/Example.pdf')
new_file = open('/home/test.pdf','w')
new_file.write(pdf_dropbox.read())我在路径/home/test.pdf中生成一个文件,它是一个PDF文件,内容显示与原始文件相同。
但是,当我使用.odt文件尝试相同的代码时,生成新文件失败:
odt_dropbox = client.get_file('/Example.odt')
new_file = open('/home/test_odt.odt','w')
new_file.write(odt_dropbox.read())这个新文件test_odt.odt有错误,我看不到它的内容。
# With this instruction I have the content of the odt file inside odt_dropbox
odt_dropbox = client.get_file('/Example.odt')odt文件内容的最佳方法吗?我很想知道任何有帮助的信息,
谢谢
发布于 2014-09-04 09:50:18
解决了,我忘了两件事:
wb而不是w的文件
new_file = open('/home/test_odt.odt','wb')new_file.close()以进行刷新完整代码:
odt_dropbox = client.get_file('/Example.odt')
new_file = open('/home/test_odt.odt','wb')
new_file.write(odt_dropbox.read())
new_file.close()https://stackoverflow.com/questions/25661806
复制相似问题