如何用python通过dropbox上传图片

2024-04-19 14:32:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试了多种方法来上传图片在Python与Dropbox API,这是非常复杂的。在

bot.command(pass_context=True)
async def upload(ctx, *, message):
   await bot.say("Downloading the file from the link, hang on...")
   url = str(message)
   wget.download(url)
   await bot.say("Done. Now uploading it to Dropbox...")
   o = os.path.basename(url)
   with open(o, "rb") as imageFile:
        f = imageFile.read()
        b = bytearray(f)
dbx.files_upload(b, '/' + o)

因为上传文件需要字节,所以我不知道该怎么做。 我总是犯这个错误

^{pr2}$

有什么我不明白的吗?在


Tags: the方法apiurlmessagebotcontext图片