声明:
因本人为AI路上的新手,文章用于辅助个人的整理记忆,理解难免有偏差之处,都是个人拙见,如给其他同僚造成困扰,还请见谅,非常非常非常欢迎私信共同讨论,共同进步
- 函数名:strip()
- 作用:去除字符串首尾指定的字符(人话见代码)
- 调用方法:str.strip([chars])
- 参数:
chars:可指定欲去除的字符元素,默认为空格
官方解释:
str.strip([chars])
Return a copy of the string with the leading and trailing characters removed.
The chars argument is a string specifying the set of characters to be removed.
If omitted or None, the chars argument defaults to removing whitespace.
The chars argument is not a prefix or suffix; rather, all combinations of its
values are stripped:
’ spacious '.strip()
‘spacious’
‘www.example.com’.strip(‘cmowz.’)
‘example’
The out