Discuss / Python / 一次过了

一次过了

Topic source

def trim(str):

while str[:1] == " ":

str = str[1:]

while str[-1:] == " ":

str = str[:-1]

return str

def trim(str):
    while str[:1] == " ":
        str = str[1:]
    while str[-1:] == " ":
        str = str[:-1]
    return str

  • 1

Reply