Discuss / Python / 洒洒水啦~

洒洒水啦~

Topic source

langangang

#1 Created at ... [Delete] [Delete and Lock User]
def trim(s):
    start = 0
    end = len(s)
    if start == end:
        return ''
    else:
        while s[start] == ' ':
            start += 1
            if (start == end):
                break
        while end >= 1 and s[end - 1] == ' ':
            end -= 1
            if (start == end):
                break
    return s[start:end]

  • 1

Reply