【发布时间】:2019-01-05 04:07:44
【问题描述】:
我正在尝试使用他们的 Python API 将图像异步上传到 Cloudinary。
他们的documentation 声明上传图片需要以下内容。
result = cloudinary.uploader.upload(file, **options)
由于我想异步上传,看来我需要将“异步”选项设置为 True(也在文档中)。
async (Boolean): 告诉 Cloudinary 是否执行上传 在后台请求(异步)。默认值:假。
由于 options 具有 **,如 this SO post 中所述,我假设该函数接受这样的关键字参数。
response = await cloudinary.uploader.upload(img, async=True)
但是,当我运行脚本时,出现以下错误:
File "async_upload.py", line 16
response = await cloudinary.uploader.upload(img, async=True)
^ SyntaxError: invalid syntax
如何在 Cloudinary 中异步上传多张图片?
【问题讨论】:
-
async现在是 Python 的保留关键字。 API 库似乎比这更旧。 -
@KlausD。啊啊啊这很有意义!嗯...我想知道我应该改用什么:L
标签: python asynchronous syntax parameters cloudinary