使用 Python (API V2) 删除 Dropbox 文件

Delete a Dropbox file using Python (API V2)

我正在尝试删除一个文件。我尝试使用: dbx.file_delete() 但是我得到一个 AttributeError。

AttributeError: 'Dropbox' object has no attribute 'file_delete'

这是我发现的 here

file_delete(path)

Delete a file or folder.

Parameters path The path of the file or folder. Returns A dictionary containing the metadata of the just deleted file.

For a detailed description of what this call returns, visit: https://www.dropbox.com/developers/core/docs#fileops-delete

我认为这是因为 file_delete() 来自 API V1,但我使用的是 API V2。我环顾四周,但找不到 API V2 文档。那么如何使用 Dropbox API V2 使用 python 删除 Dropbox 上的文件?

谢谢!

根据 Dropbox APIv2 documentation,删除文件或文件夹的方法是:

dbx.files_delete(path)

哪里dbx = dropbox.Dropbox(access_token)

dbx.files_delete(path)

已弃用。使用

dbx.files_delete_v2(path)

相反。