Discuss / Python / 贴个自己的答案,比较菜,主要来学习

贴个自己的答案,比较菜,主要来学习

Topic source

dly君

#1 Created at ... [Delete] [Delete and Lock User]

def trim(s): i=0 j=-1 if len(s) == 0: return '' while i<len(s) and s[i]==' ': i += 1 if i==len(s): return '' while s[j]==' ': j += -1 if j==-1: return s[i:] return s[i:(j+1)]


  • 1

Reply