【发布时间】:2022-01-27 08:21:51
【问题描述】:
我正在尝试使用 python API 将“txt”文件上传到保管箱。 在到处寻找之后,我知道我没有发现任何有用的东西,或者我只是不明白如何让它发挥作用。
with open('Hello.txt') as f:
dbx.files_upload(f,'/PythonClass/data_src')
我也试过这个:
with open('Hello.txt') as f:
dbx.files_upload(f.read(), folder_py_src, mode=WriteMode('overwrite'))
还有这个:
with open('Hello.txt', "rb") as f:
dbx.files_upload(f.read(), folder_py_src, mode=WriteMode('overwrite'))
我收到一个错误:
Traceback (most recent call last):
File "c:\Users\User\Desktop\pytask\classprojectdropbox", line 46, in <module>
dbx.files_upload(f.read(), folder_py_src, mode=WriteMode('overwrite'))
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\dropbox\base.py", line 2931, in files_upload
r = self.request(
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\dropbox\dropbox_client.py", line 348, in request
raise ApiError(res.request_id,
dropbox.exceptions.ApiError: ApiError('2d7014d399964557a8658a49ae90ef75', UploadError('path', UploadWriteFailed(reason=WriteError('conflict', WriteConflictError('folder', None)), upload_session_id='pid_upload_session:TOKEN')))
【问题讨论】:
-
将其更改为
with open("Hello.txt", "rb") as f:有帮助吗? -
我也试过了,没用