循环 if 切片
Topic sourcedef trim(s):
while s[:1] == ' ' or s[-1:] == ' ':
if s[:1] == ' ':
s = s[1:]
elif s[-1:] == ' ':
s = s[:-1]
return s
- 1
def trim(s):
while s[:1] == ' ' or s[-1:] == ' ':
if s[:1] == ' ':
s = s[1:]
elif s[-1:] == ' ':
s = s[:-1]
return s
ClearIight