Python 3.x 制作屏幕截图并使用discord.py发送,但不保存
例如,我可以拍摄一张屏幕截图,然后直接发送图像而不保存它吗?Python 3.x 制作屏幕截图并使用discord.py发送,但不保存,python-3.x,discord,discord.py,Python 3.x,Discord,Discord.py,例如,我可以拍摄一张屏幕截图,然后直接发送图像而不保存它吗? 我已经尝试先保存它,但是Raspberry pi有Python无法保存的东西。我不明白你的意思,但是你可以发送图像而不保存它 import io from PIL import Image @bot.command(name="red") async def red_command(ctx): image = Image.new("RGB", (400, 200), (255, 0,
我已经尝试先保存它,但是Raspberry pi有Python无法保存的东西。我不明白你的意思,但是你可以发送图像而不保存它
import io
from PIL import Image
@bot.command(name="red")
async def red_command(ctx):
image = Image.new("RGB", (400, 200), (255, 0, 0))
b = io.BytesIO()
image.save(b, format="png")
b.seek(0)
file = discord.File(b, "red.png")
await ctx.send(file=file)
你通常如何拍摄截图?你尝试过什么?我从来没有在Raspberry pi上截图过,但是在python中我会使用Pyautogui。是的,谢谢,我需要它