美文网首页
python strip( )函数

python strip( )函数

作者: 木有枝兮 | 来源:发表于2019-12-08 21:37 被阅读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

相关文章

网友评论

      本文标题:python strip( )函数

      本文链接:https://www.haomeiwen.com/subject/wblvgctx.html