python strip( )函数
2019-12-08 本文已影响0人
木有枝兮
一、默认用法:去除空格
str.strip() : 去除字符串两边的空格
str.lstrip() : 去除字符串左边的空格
str.rstrip() : 去除字符串右边的空格
注:此处的空格包含'\n', '\r', '\t', ' '
a=' abc de a 1'
1 print(a.strip())
2 print(a.lstrip())
3 print(a.rstrip())
输出结果:
1 abc de a 1
2 abc de a 1
3 abc de a 1