2016-01-23 62 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