while len(s) and s[0]==' ':
s=s[1:]
while len(s) and s[-1]==' ':
s=s[:-1]
if len(s)==0:
return ''
else:
return s
大佬 自学小白想问下 while len(s) and s[0]==' ': 这个len(s)在这里起什么作用啊
这一段
while len(s) and s[0] == ' ':
实际上是下面这一段的意思
while len(s) != 0 and s[0] == ' ':
真心感谢
Sign in to make a reply
会啊员专啊属昵称
while len(s) and s[0]==' ':
s=s[1:]
while len(s) and s[-1]==' ':
s=s[:-1]
if len(s)==0:
return ''
else:
return s