【发布时间】:2021-11-06 19:15:16
【问题描述】:
@bot.on(events.CallbackQuery)
async def handler(event):
global fotomandate
global i
if event.data == b"1":
await event.respond("how many photos do i send?")
numerofoto = int(input("how many photos do i send?")) ##ignore this line i'll fix later
print (numerofoto)
while i < numerofoto:
path = (r"C:\Users\x\Desktop\Nuova cartella (2)")
fotorandom = random.choice([
x for x in os.listdir(r"C:\Users\x\Desktop\Nuova cartella (2)")
if os.path.isfile(os.path.join(path, x))
])
i += 1
await event.reply(file=fotorandom)
我需要从目录中发送 n(在电报中输入)随机照片,但它说
ValueError:无法将 bonni media-jpg 转换为媒体。不是现有文件、HTTP URL 或有效的类似 bot API 的文件 ID
【问题讨论】: