python-telegram-bot - send_photo() 缺少 1 个必需的位置参数:'self'
python-telegram-bot - send_photo() missing 1 required positional argument: 'self'
发送照片时出现此错误:
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_id
和photo
。我还使用了 .sendPhoto
我不知道为什么会出现 send_photo()
错误。是错误还是我遗漏了什么?
您应该使用 Bot()
的实例而不是 Bot
,
例如bot = Bot()
然后做 bot.sendPhoto(chat_id=update.effective_user.id,photo=open(f'{os.getcwd()}\{update.effective_user.id}\{i}', 'rb'))
发送照片时出现此错误:
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_id
和photo
。我还使用了 .sendPhoto
我不知道为什么会出现 send_photo()
错误。是错误还是我遗漏了什么?
您应该使用 Bot()
的实例而不是 Bot
,
例如bot = Bot()
然后做 bot.sendPhoto(chat_id=update.effective_user.id,photo=open(f'{os.getcwd()}\{update.effective_user.id}\{i}', 'rb'))