Discuss / Python / 简洁一点。。。

简洁一点。。。

Topic source

李uxuxu

#1 Created at ... [Delete] [Delete and Lock User]
def trim(s):
    while len(s) != 0 and s[0] == ' ':
        s = s[1:]
    while len(s) != 0 and s[len(s) - 1] == ' ':
        s = s[:len(s) - 1]
    return s

  • 1

Reply