此语法在python中执行什么功能

问题描述 投票:0回答:1

请解释longestCommonPrefix函数的参数中的语法。此函数将字符串列表作为输入。

class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:


python
1个回答
2
投票

参数和->描述了函数的类型。

def longestCommonPrefix(self, strs: List[str]) -> str:
    pass

因此需要一个参数strs,它是字符串列表[List[str])。然后它返回一个字符串(str)。

© www.soinside.com 2019 - 2024. All rights reserved.