def trim(str): bol = True bol_2 = True while(bol or bol_2): if(str[0] == " "): str = str[1:] bol = True else: bol = False
if(str[-1] == " "): str = str[0:-1] bol_2 = True else: bol_2 = False return str
Sign in to make a reply
用户pmpg6eaxw1
def trim(str): bol = True bol_2 = True while(bol or bol_2): if(str[0] == " "): str = str[1:] bol = True else: bol = False