80 def trim(s):
81 if s == '':
82 return ''
83 str = s
84 while str[0] == ' ':
85 str = str[1:]
86 if str == '':
87 return ''
88 while str[-1] == ' ':
89 str = str[:-1]
90 if str == '':
91 return ''
92 return str
90,91行可以去掉。
Sign in to make a reply
立冬前后
80 def trim(s):
81 if s == '':
82 return ''
83 str = s
84 while str[0] == ' ':
85 str = str[1:]
86 if str == '':
87 return ''
88 while str[-1] == ' ':
89 str = str[:-1]
90 if str == '':
91 return ''
92 return str