【发布时间】:2022-10-17 16:56:08
【问题描述】:
我得到这个异常:“发生异常:AttributeError __aenter__”在async with bot: 行。 (我输入了令牌)。请帮忙
import asyncio
import telegram
async def main():
bot = telegram.Bot("token")
async with bot:
print(await bot.get_me())
if __name__ == '__main__':
asyncio.run(main())
我在这里找到了这段代码:https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API
【问题讨论】:
-
你安装了哪个版本的 python-telegram-bot 包?
-
python-telegram-bot 13.11 |机器人 API 5.7 |证书 2022.05.18.1 | Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 位 (AMD64)]
-
哦。 github 中的文档适用于 20.x 版本。我得到它
标签: python python-asyncio python-telegram-bot