我已经阅读了带有正则表达式过滤意外字符的 Python str.strip()帖子和官方文档(这是针对 python 2,但是,在 python 3 中,它不再存在)。
我有点困惑。结果,我做了如下实验。
>>> 'hello'.strip('o')
'hell'
>>> 'hello.hello'.strip('.hello')
''
>>> 'hello.hello'.strip('.o')
'hello.hell'
>>> 'hello.hello'.strip('o.')
'hello.hell'
>>> 'Hello.hello'.strip('H')
'ello.hello'
>>> 'Hello.hello'.strip('H.')
'ello.hello'
>>> 'HEllo.hello'.strip('E')
'HEllo.hello'
>>> 'HEllo.hEllo'.strip('E')
'HEllo.hEllo'
>>> 'HEllo.hEllo'.strip('HE')
'llo.hEllo'
>>> 'HEllo.hEllo'.strip('El')
'HEllo.hEllo'
>>> 'HEllo.hEllo'.strip('Eo')
'HEllo.hEll'
>>> 'HEllo.hEllo'.strip('.h')
'HEllo.hEllo'
>>> 'HEllo.hEllo'.strip('o.h')
'HEllo.hEll'
>>> 'HEllo.hEllo'.strip('o-h')
'HEllo.hEll'
>>> 'HEllo.hEllo'.strip('hello')
'HEllo.hE'
>>> 'hello.hello'.strip('hello')
'.'
Run Code Online (Sandbox Code Playgroud)
我不知道上面的一些结果。
谁能给我一个解释?
为什么这个区域从 python 3 文档中删除?