更新时间:2023-11-24 23:07:46
你不能在 2.7 中直接使用新的 (3.5+) 注释语法,但是如果你有 python 3.4+ 你可以安装 mypy 并在你的机器上运行它2.7 不同语法的代码.请参阅 PEP 484.
You can't use the new (3.5+) annotation syntax directly in 2.7, but if you have python 3.4+ you can install mypy and run it on your 2.7 code with a different syntax. See PEP 484.
您在链接中指向的示例可以在 2.7 中编写为:
The example you pointed to in your link could be written in 2.7 as:
class Completion:
def __init__(self, start, end, text, type=None, _origin=''):
# type: (int, int, str, str, str) -> None
...