print('abdpab sa'.strip('pab'))
为什么结果是:'dpab s'
1
virusdefender 2017-07-29 11:36:46 +08:00 3
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
explist OP 原来如此,谢谢
|
3
symons 2017-08-09 21:30:21 +08:00
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. |