while len(s)>0 and s[0] == ' ':
s = s[1:]
while len(s)>0 and s[-1] == ' ':
s = s[:-2]
return s
倒数第二行应该是 s = s[:-1]吧?
Sign in to make a reply
王一二_biu
while len(s)>0 and s[0] == ' ':
s = s[1:]
while len(s)>0 and s[-1] == ' ':
s = s[:-2]
return s