Python 字符串处理函数—strip使用探究
1.菜鸟教程对strip的描述
Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列。
注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符。
2.官方源码给出的描述:
Return a copy of the sequence with specified leading and trailing bytes removed.
3.strip()函数语法
Str.strip([chars])
例如:
>>> ‘hash’.strip(‘abcd’)
从以上描述中可以发现几个关键字:“头尾”、“trailing”、“中间”,这些