Answer the question
In order to leave comments, you need to log in
What is the error, Python Aiogram?
I don't understand what the error is and I don't understand how to fix this error. the code:
async def hellopicture(dp: Dispatcher):
files = random.choice(list(os.walk('C:/Users/andis/Desktop/Python/EasyBot/Picture'))[0][-1])
img = open(files, 'rb')
print(img)
img.close()
photo = types.InputFile(path_or_bytesio=files)
await dp.bot.send_photo(config.GROUP_ID, photo=photo)
def scedule_jobs2():
scheduler.add_job(hellopicture, "interval", seconds = 10, args=(dp, ))
scedule_jobs2()
Answer the question
In order to leave comments, you need to log in
Everything is written in English here, and everything is clear
. The translation of the error is something like this:
I can’t find the file or directory '4.jpg'
The problem is that you only looked at the path to these pictures, but when you try to take this file, the bot is in your directory (That is, where you launched the .py script)
files = random.choice(list(os.walk('C:/Users/andis/Desktop/Python/EasyBot/Picture'))[0][-1])
img = open(f'C:/Users/andis/Desktop/Python/EasyBot/Picture/{files}', 'rb')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question