求助:为何出现AttributeError: 'Update' object has no attribute 'reply_document'错误?
AttributeError: 'Update' object has no attribute 'reply_document' 问题解析
- 问题本质:
reply_document并非Update类的方法,你搞错了API的调用对象。 - 针对python-telegram-bot库的修正方案:
- 若使用v13+版本:
必须通过Context对象的bot实例调用send_document方法,示例:context.bot.send_document( chat_id=update.effective_chat.id, document=open("your_file.pdf", "rb") ) - 若使用v12及更早版本:
可通过update.message对象调用reply_document(前提是update.message不为空),示例:update.message.reply_document(document=open("your_file.pdf", "rb"))
- 若使用v13+版本:
- 注意:无论哪个版本,
Update对象本身都没有reply_document方法,不要直接在update上调用该方法。
内容的提问来源于stack exchange,提问作者Ross Smith
相关产品推荐
相关产品推荐

