如何使用text strip()函数?

Vic*_*Vic 2 python string python-3.x

我可以删除数字,但不能删除字母字符:

>>> text
'132abcd13232111'

>>> text.strip('123')
'abcd'
Run Code Online (Sandbox Code Playgroud)

为什么以下不起作用?

>>> text.strip('abcd')
'132abcd13232111'
Run Code Online (Sandbox Code Playgroud)

Jim*_*ard 6

原因很简单,在文档strip中有说明:

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.
Run Code Online (Sandbox Code Playgroud)

'abcd'既不是字符串的前导,也不是尾随,'132abcd13232111'因此不会被删除。