trim字符串

假定在Python定义了字符串str:

>>>str=" gho stwwl "

一、同时去掉左右两边的空格

>>>str.strip()
'gho stwwl'

二、去掉左边的空格

>>>str.lstrip()
'gho stwwl '

三、去掉右边的空格

>>>str.rstrip()
' gho stwwl'