Discuss / Python / 作业

作业

Topic source

立冬前后

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

 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

立冬前后

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

90,91行可以去掉。


  • 1

Reply