作业试试
Topic source缩进怪怪得
def trim(s):
if not isinstance(s, str):
raise TypeError
n = len(s)
l = 0
while (l < n) and (s[l] == ' '):
l += 1
r = n
while (r > l) and (s[r - 1] == ' '):
r -= 1
return s[l:r] if l < r else ''
- 1
蝶殇/yl待月