繁体   English   中英

Dropbox Python API无法更新文件

[英]Dropbox Python API not updating file

我的代码正在将txt文件上传到我的保管箱,但是它本身的文档中没有内容。 它仅读取文件“ test_data.txt”的标题内,而实际文件中的数据本身不存在。 该文件永远不会在第二次运行脚本时更新,但是我怀疑这是因为该文件没有被更新(实际上不是在读取.txt文件的内容)。 如果有人可以帮助我,我将不胜感激。

import dropbox
from dropbox.files import WriteMode
overwrite = WriteMode('overwrite', None)

token = 'xxxx'

dbx = dropbox.Dropbox(token)
dbx.users_get_current_account()
dbx.files_upload('test_data.txt', '/test_data.txt', mode = WriteMode('overwrite'))

files_upload应该收到要上传的内容。 在您当前的代码中,您要上传字符串“ test_data.txt ”作为文件“ /test_data.txt ”。

with open('test_data.txt', 'rb') as fh:
    dbx.files_upload(fh.read(), '/test_data.txt')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM