Discuss / Python / 递归方法

递归方法

Topic source

    if s[:1] == ' ' and s[-1:] == ' ':

        return trim(s[1:-1])

    elif s[:1] == ' ':

        return trim(s[1:])

    elif s[-1:] == ' ':

        return trim(s[:-2])

    else:

        return s

星觅夜

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

这个方法代码最简洁,好厉害


  • 1

Reply