【问题标题】:Python-telegram-bot syntax error for the line "_id_attrs: Tuple[Any, ...] = ()"行“_id_attrs: Tuple[Any, ...] = ()”的 Python-telegram-bot 语法错误
【发布时间】:2021-01-26 16:46:48
【问题描述】:

我已经在 ubuntu 上通过 pip 和 pip3 安装了 python-telegram-bot 包并尝试加载它:

from telegram.ext import Updater, CommandHandler

然后我得到:

File "/usr/local/lib/python3.5/dist-packages/telegram/base.py", line 42

_id_attrs: Tuple[Any, ...] = ()
         ^
SyntaxError: invalid syntax

我在 python 2.7 版本中遇到了类似的错误。 “base.py”文件中有一行“_id_attrs:”,我使用 python 已经有一段时间了,从来没有见过变量名后跟冒号。是什么意思让这行代码对 python 可读。

【问题讨论】:

    标签: python bots telegram


    【解决方案1】:

    您必须将您的 python 版本更新到至少 3.6。 python 3.6中引入了语法(来自错误)(检查PEP-526)。

    另外,the library's Documentation 中明确说明必须使用 v3.6+。

    这个库为 Telegram Bot 提供了一个纯 Python 接口 API。 It's compatible with Python versions 3.6+. PTB 也可能在 PyPy,虽然之前有很多问题。因此,PyPy 是 未得到官方支持。

    【讨论】:

    • 谢谢,感谢您的帮助。
    猜你喜欢
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多