Discuss / Python / 好像没有人用递归函数实现?

好像没有人用递归函数实现?

Topic source

疾风_90334

#1 Created at ... [Delete] [Delete and Lock User]

    if len(s) == 0:

        return ''

    else:

        if s[0] == ' ':

            return trim(s[1:])

        elif s[-1] == ' ':

            return trim(s[:-1])

        else:

            return s

用递归函数貌似也可以实现。

大水杉

#2 Created at ... [Delete] [Delete and Lock User]


  • 1

Reply