def trim(s): i,ci,cj = 0,0,0 j = 1 while i < len(s)-1: if s[i] == ' ': i += 1 ci += 1 else: break while j < len(s): if s[-j] == ' ': j += 1 cj += 1 else: break if ci>0 and cj>0: return s[ci:-cj]
elif ci==0 and cj>0: return s[:-cj]
elif ci>0 and cj==0: return s[ci:]
else: return s
看见没又今天了