【发布时间】:2021-11-14 19:49:58
【问题描述】:
我的不和谐机器人在某个命令后创建二维码。但是我无法将此二维码作为消息发送给用户:
import qrcode
def create_qr_code(string : str):
qr = qrcode.make(string)
return qr
# sending qr to user
qr_code = create_qr_code('some text')
# check if qr_code is None
print(qr_code)
await ctx.send(file=discord.File(fp=qr_code))
我的print 语句返回类似
<qrcode.image.pil.PilImage object at 0x000001BD735FCF28>,
这很好,告诉我二维码的创建是成功的。 我想知道为什么发送它似乎不起作用。
【问题讨论】:
-
您不能向频道发送 base64 编码字符串吗?或作为一个blob
-
为了简单起见,为什么在上传临时文件后必须删除它们......?
-
不,这不是问题,我认为使用
save功能可以永久保存
标签: python file discord bots qr-code