Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
def romanToInt(self, s: str) -> int
这是函数名,这种格式在 python 中使用。我很困惑为什么我们使用这个箭头以及为什么我们int在s. 有人可以解释一下吗?
int
s
它们是函数注释。
->标记返回函数注释,指示函数返回一个int.
->
: str指示字符串参数。
: str
你可以在这里阅读更多关于它们的信息。
或者,SO:-> 在 Python 函数定义中是什么意思?