def trim(s): for i in s: if s[:1] ==' ': s = s[1:] if s[-1] ==' ': s = s[0:-1] return s
感觉这个很棒啊
trim(‘ ’)这样全是空格的会报错
Sign in to make a reply
彩虹