jas*_*son 8 arguments function python-3.x
?在python3中找到如下代码:
def twoSum(self, nums: List[int], target: int) -> List[int]:
return sum(nums)
Run Code Online (Sandbox Code Playgroud)
正如我所知道的 python def
,我们只需要遵循:
def twoSum(self, nums, target):
return sum(nums)
Run Code Online (Sandbox Code Playgroud)
什么是nums: List[int], target: int
和->List[int]
手段?那些是python 3的新特性吗?我从来没有见过那些。
谢谢,
小智 7
from typing import List
def twoSum(nums: List[int], target: int) -> List[int]:
print(nums, target)
Run Code Online (Sandbox Code Playgroud)
链接: https: //docs.python.org/3/library/typing.html
注意 Python 运行时不强制执行函数和变量类型注释。它们可以被第三方工具使用,例如类型检查器、IDE、linter 等。
链接: https: //code.visualstudio.com/docs/python/linting
归档时间: |
|
查看次数: |
8320 次 |
最近记录: |