Discuss / Python / 方法比较笨点

方法比较笨点

Topic source

def trim(s): if s=='': return s x=0 y=-1 while s[x]==' ': x=x+1 if x==len(s): s='' return s if s[y]!=' ': s=s[x:] return s while s[y]==' ': y=y-1 s=s[x:y+1] return s 可能没大家做的精妙,但测试还是成功了,自我呱唧呱唧,同时去学一下大家的方法


  • 1

Reply