python - 如何从discordpy中的文件发送图像
问题描述
所以基本上我正在尝试从 discord.py 中的文件夹发送图像。我想不通。这是我到目前为止所拥有的......
async def neko(ctx):
neko =[]
for x in os.listdir("neko"):
neko.append(x)
await ctx.send(random.choice(neko))```
It sends the filename but it does not send the actual image.
解决方案
你没有完全得到图像。试试下面的代码,如果它不起作用,你可以随时使用这个PIL
包
async def neko(ctx):
neko_list =[]
for x in os.listdir("neko"):
neko_list.append(x)
neko = random.choice(neko_list)
await ctx.send(file=discord.File(neko))
推荐阅读
- python - h5py 查看器无法打开它/以编程方式调用
- marklogic - Marklogic 二级排序如何工作?
- python-3.x - 如何将数据列表(括号中的每个值)转换为 python 列表形式?
- actions-on-google - AndroidTV 上的 Google 助理不显示表格
- angular - (Angular 2/4/5/6)更改浏览器后退按钮的导航
- sql-server - SQL Server:从调用其他存储过程的存储过程中捕获临时表
- python - 在 DjangoModelFactory 中使用 Django faker 创建的克隆模型字段
- javascript - TypeScript 针对错误的 ECMAScript 版本
- firebase-realtime-database - firebase 功能 INVALID_ARGUMENT HTTP 错误 400 在部署
- javascript - 在输入 4 位密码时删除最后一个字母的字母间距?