Discuss / Python / 有点不一样

有点不一样

Topic source
def trim(s):
 if s[0]!=' ' and s[-1]!=' ':
  print(s)
 else:
  if s[0]==' ':
   s=s[1:]
  if s[-1]==' ':
   s=s[:-1]
  trim(s)

  • 1

Reply