python有strip()、lstrip()、rstrip()这样的三个函数,官方文档是这样解释的:
str. strip ( [ chars ] )Return a copy of the string with the leading and trailing characters removed. Thechars argument is a string specifying the set of characters to be removed. If omitted orNone, thechars argument defaults to removing whitespace. Thechars argument is not a prefix or suffix; rather, all combinations of its values are stripped:
>>> ' spacious '.strip()
'spacious'
>>