上海品牌网站设计,个人网站,可以做淘宝客吗,短信营销平台,免费制作动画网站strip()函数 去空格nrt函数的用法
strip 同时去掉左右两边的空格#xff08;推荐学习#xff1a;Python视频教程#xff09;
lstrip 去掉左边的空格
rstrip 去掉右边的空格
具体示例如下#xff1a;a hello world#xff01;#xff01;
推荐学习Python视频教程
lstrip 去掉左边的空格
rstrip 去掉右边的空格
具体示例如下a hello world
a.lstrip() hello world
a.rstrip() hello world
a.strip() hello world
声明s为字符串rm为要删除的字符序列
s.strip(rm) 删除s字符串中开头、结尾处位于 rm删除序列的字符
s.lstrip(rm) 删除s字符串中开头处位于 rm删除序列的字符
s.rstrip(rm) 删除s字符串中结尾处位于 rm删除序列的字符
注意
当rm为空时默认删除空白符包括’n’, ‘r’, ‘t’, ’ ) a hello worlda.strip()
hello worldatthello world
hello worlda hello worldrna.strip()
hello world
更多Python相关技术文章请访问Python教程栏目进行学习
以上就是小编分享的关于Python怎么去掉最后的空格的详细内容希望对大家有所帮助更多有关python教程请关注环球青藤其它相关文章