print('abdpab sa'.strip('pab'))
为什么结果是:'dpab s'
print('abdpab sa'.strip('pab'))
为什么结果是:'dpab s'
|
1
Return a copy of the string with leading and trailing characters removed. If chars is omitted or None, whitespace characters are removed. If given and not None, chars must be a string; the characters in the string will be stripped from the both ends of the string this method is called on.
好好理解最后一句 |
|
2
原来如此,谢谢
|
|
symonsAug 9, 2017
3
1 Docstring for builtins:function strip
2 ======================================== 3 S.strip([chars]) -> str 4 5 Return a copy of the string S with leading and trailing 6 whitespace removed. 7 If chars is given and not None, remove characters in chars instead. |