【问题标题】:python-telegram-bot - send_photo() missing 1 required positional argument: 'self'python-telegram-bot - send_photo() 缺少 1 个必需的位置参数:'self'
【发布时间】:2021-04-24 07:05:22
【问题描述】:

我在发送照片时收到此错误:

Bot.sendPhoto(chat_id=update.effective_user.id,photo=open(f'{os.getcwd()}\\{update.effective_user.id}\\{i}', 'rb'))
TypeError: send_photo() missing 1 required positional argument: 'self'

我不知道如何设置self那里,我根据this issue编写代码,我坐在chat_idphoto。我还使用了.sendPhoto 我不知道为什么会收到send_photo() 错误。是错误还是我错过了什么?

【问题讨论】:

    标签: python python-telegram-bot


    【解决方案1】:

    您应该使用 Bot() 而不是 Bot 的实例,

    例如bot = Bot() 然后做bot.sendPhoto(chat_id=update.effective_user.id,photo=open(f'{os.getcwd()}\\{update.effective_user.id}\\{i}', 'rb'))

    【讨论】:

    • bot = Bot(token) 你的意思是,pog 反正
    • 当然,传递实例化Bot(...)所需的任何参数
    猜你喜欢
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    • 2023-02-06
    • 2020-11-15
    • 2021-09-15
    • 2013-07-06
    相关资源
    最近更新 更多