使用此功能:
def array_returner():
return ["hello", "there"]
我将如何键入此函数返回一个字符串数组而不导入List(并使用List[str]
语法?)?
您可以这样做
def array_returner() -> [str]:
def array_returner() -> List[str]:
(from typing import List
)这是您要寻找的:
from typing import List
def array_returner() -> List[str]:
return ["hello", "there"]