Discuss / Python / 这样?

这样?

Topic source

机智豆_RD

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

def trim(s):

    if len(s)==0:

        return s

    elif len(s)!=0:

        if s[0:1]==' ':

            return trim(s[1:])

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

            return trim(s[:-1])

    print(s)


  • 1

Reply