2016-01-23 61 views
2

我想用Python 3.4覆盖Dropbox上的文件,但无法弄清楚如何去做。如果文件不存在,dbx.files_upload(data, '/file.py')按预期创建文件。用Python中的Dropbox API v2覆盖文件

但是,如果文件存在,我想覆盖它。我试过

dbx.files_upload(data, '/file.py', mode=WriteMode('overwrite')) 

这给

NameError: name 'WriteMode' is not defined 

,我已经试过

dbx.files_upload(data, '/iot_main.py', overwrite=True) 

这给

TypeError: files_upload() got an unexpected keyword argument 'overwrite' 

我觉得如果我想的东西很明显,但很多谷歌搜索答案没有帮助。 ..

谢谢。

回答

1

只需在您的文件中添加它。

from dropbox.files import WriteMode