def trim(s): while s[:1]==' ': s= s[1:] while s[-1:]==' ': s=s[:-1] return s
应该是这个最简单,顶上去
点赞
为什么我把while换成if就不行了
Sign in to make a reply
释放心中怒火
def trim(s): while s[:1]==' ': s= s[1:] while s[-1:]==' ': s=s[:-1] return s