相关疑难解决方法(0)

Python 3注释:键入提示指定类型的列表(PyCharm)

使用Python 3的函数注释,可以指定同类列表(或其他集合)中包含的项目类型,以便在PyCharm和其他IDE中进行类型提示?

int列表的伪python代码示例:

def my_func(l:list<int>):
    pass
Run Code Online (Sandbox Code Playgroud)



我知道可以使用Docstring ...

def my_func(l):
    """
    :type l: list[int]
    """
    pass
Run Code Online (Sandbox Code Playgroud)

...但如果有可能,我更喜欢注释样式.

python type-hinting pycharm python-3.x

93
推荐指数
4
解决办法
3万
查看次数

标签 统计

pycharm ×1

python ×1

python-3.x ×1

type-hinting ×1