def trim(s): while s[:1]==' ': s=s[1:] while s[-1:]==' ': s=s[:-1] return s S=input('输入一个前后带空格的字符串:') print('去除前后空格后,字符串为:',trim(S))
Sign in to make a reply
Knight___Spirit