discord py,尝试发送图像

试图发送图像


从帖子中复制了这段代码,我添加了一些。


ch = get(member.guild.channels, name="general")

# where i want to send an image 


#this is my animated gif from this line I copied but no idea where Image function come from 

image = Image.open("./images/welcome.gif")


with BytesIO() as image_binary:

   image.save(image_binary, "gif")

   image_binary.seek(0)

   await ch.send(file=discord.File(fp=image_binary))

我通过 pip 安装了 Image 并添加了 import Image 然后出现错误


所以我认为这不是来自 pip 的模块


有任何想法吗?


慕桂英3389331
浏览 73回答 1
1回答

陪伴而非守候

你会想要Pillow图书馆。pip install PillowImage然后,从导入PIL:from PIL import Image
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python