Discuss / Python / yi ce shi cheng gong

yi ce shi cheng gong

Topic source

def trim(s): n=0 m=-1 l=len(s) if l==0: s='' else: while True: if n==l: break elif s[n]!=' ': break n=n+1 while True: if n==l: break elif s[m]!=' ': break m=m-1 m=m+1 if n==m: s=s[n] elif n==l: s='' elif m==0: s=s[n:] else: s=s[n:m] return s


  • 1

Reply