Discuss / Python / 献丑

献丑

Topic source

def trim(a=None):

    if a is None:

        a = ""

    for i in range(0, int(len(a) / 2)):

        if a[i:i+1] == " ":

            pass

        else:

            frt = i

            break

    for j in range(-1, -int(len(a) / 2),-1):

        if a[j - 1:j] == " ":

            pass

            print(a[j - 1:-j])

        else:

            print(a[j - 1:-j])

            ed = j

            break

    s = a[frt:ed]

    print(s)

    return s

b = trim("  Hello World    ")


  • 1

Reply