Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x discord.py-发送虚拟PDF文件_Python 3.x_Discord_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python 3.x discord.py-发送虚拟PDF文件

Python 3.x discord.py-发送虚拟PDF文件,python-3.x,discord,discord.py,discord.py-rewrite,Python 3.x,Discord,Discord.py,Discord.py Rewrite,是否有办法将虚拟PDF文件上载到Discord(我不希望在我的计算机上创建文件)。我已经知道我可以通过以下方式发送虚拟txt文件: 导入不一致,异步 从discord.ext导入命令 从io导入StringIO bot=commands.bot() @bot.command() 异步def发送(ctx,*,字符串): 等待ctx.send(file=discord.file( fp=StringIO(“这是一项测试”), filename=“Test.txt” ) 但这不适用于PDF文件。我尝

是否有办法将虚拟PDF文件上载到Discord(我不希望在我的计算机上创建文件)。我已经知道我可以通过以下方式发送虚拟
txt
文件:

导入不一致,异步
从discord.ext导入命令
从io导入StringIO
bot=commands.bot()
@bot.command()
异步def发送(ctx,*,字符串):
等待ctx.send(file=discord.file(
fp=StringIO(“这是一项测试”),
filename=“Test.txt”
)
但这不适用于PDF文件。我尝试改用,但没有结果。有人知道如何解决此问题吗?

下面是一个使用的示例:

导入不一致
从discord.ext导入命令
从io导入字节io
从fpdf导入fpdf
bot=commands.bot(“!”)
@bot.command()
异步定义pdf(ctx,*,文本):
pdf=FPDF()
pdf.add_page()
pdf.set_字体('Arial','B',16)
pdf.cell(40,10,文本)
bstring=pdf.output(dest='S').encode('latin-1'))
等待ctx.send(file=discord.file(BytesIO(bstring),filename='pdf.pdf'))
bot.run(“令牌”)
下面是一个使用以下内容的示例:

导入不一致
从discord.ext导入命令
从io导入字节io
从fpdf导入fpdf
bot=commands.bot(“!”)
@bot.command()
异步定义pdf(ctx,*,文本):
pdf=FPDF()
pdf.add_page()
pdf.set_字体('Arial','B',16)
pdf.cell(40,10,文本)
bstring=pdf.output(dest='S').encode('latin-1'))
等待ctx.send(file=discord.file(BytesIO(bstring),filename='pdf.pdf'))
bot.run(“令牌”)