def trims(s):
if s == None:
print("s is NULL")
i = 0
j = -1
while i<len(s) and s[i] == ' ':
i = i + 1
while j+len(s)>0 and s[j] == ' ':
j = j - 1
s=s[i:len(s)+j+1]
return s
Sign in to make a reply
蟹老板
def trims(s):
if s == None:
print("s is NULL")
i = 0
j = -1
while i<len(s) and s[i] == ' ':
i = i + 1
while j+len(s)>0 and s[j] == ' ':
j = j - 1
s=s[i:len(s)+j+1]
return s