在Python 3.7之后编写键入提示的哪种方法更好?

时间:2018-04-20 07:20:25

标签: python python-3.x typing

在带有PEP 563的Python 3.7中,有两种写入输入提示的方法:

from typing import List

def merge(xs: List[int], ys: List[int]) -> List[int]:
    return xs + ys

def merge(xs: list[int], ys: list[int]) -> list[int]:
    return xs + ys

两者看起来都是一样的。哪个是推荐的?

编辑:PyCharm已经支持第二种方式 enter image description here

0 个答案:

没有答案