python去字符串空格

原文链接:https://blog.csdn.net/zhangfengwusha/article/details/28389853 

字符串里有三个去空格的函数
strip 同时去掉左右两边的空格
lstrip 去掉左边的空格
rstrip 去掉右边的空格

>>>a=" gho stwwl "
>>>a.lstrip()
'gho stwwl '
>>>a.rstrip()
' gho stwwl'
>>>a.strip()
'gho stwwl'
 

猜你喜欢

转载自blog.csdn.net/y_f_raquelle/article/details/83539497
今日推荐