if len(s) == 0:
return ''
else:
if s[0] == ' ':
return trim(s[1:])
elif s[-1] == ' ':
return trim(s[:-1])
return s
用递归函数貌似也可以实现。
棒
Sign in to make a reply
疾风_90334
if len(s) == 0:
return ''
else:
if s[0] == ' ':
return trim(s[1:])
elif s[-1] == ' ':
return trim(s[:-1])
else:
return s
用递归函数貌似也可以实现。