S
S
SandPie2021-06-09 19:13:19
Python
SandPie, 2021-06-09 19:13:19

Why does it throw an error: TypeError: open() takes 1 positional argument but 2 were given?

I don’t understand why it gives me an error TypeError: open() takes 1 positional argument but 2 were given, because before everything worked fine, but now this.
Code snippet with an error:

@bot.message_handler(commands = ['screenshot'])
def screenshot(message):
    pg.screenshot('screenshot.png')

    with open('screenshot.png', 'rb') as img:
        bot.send_photo(message.chat.id, img)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-06-09
@SandPie

Looks like you've overridden open by creating your own function with that name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question