This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: lstrip remove extra characters in the presence of a matching number
类型: behavior Stage: resolved
Components: Versions: Python 3.5, Python 2.7
process
状态: closed Resolution: not a bug
Dependencies: 后续:
分配给: 抄送列表: Akilesh K, christian.heimes
优先级: normal 关键字:

Created on 2019-05-31 12:40 by Akilesh K, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg344070 - (view) Author: Akilesh K (Akilesh K) 日期: 2019-05-31 12:40
When the argument to lstrip / strip has a number and it matches the string it begins to act different. 

>>> text = "apiv1appliance"
>>> text.strip("apiv1")
'liance'
>>> text.strip("apiv2")
'1appliance'
>>> text.strip("a")
'piv1appliance'
>>> text.strip("ap")
'iv1appliance'
>>> text.strip("api")
'v1appliance'
>>> text.strip("apiv")
'1appliance'
>>> text.strip("apiv1")
'liance'
>>> text.strip("apiv2")
'1appliance'
msg344072 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) 日期: 2019-05-31 12:43
It's not a bug. strip() does not work like you think. Please read the documentation https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip
历史
日期 用户 动作 参数
2022-04-11 14:59:16admin修改github: 81295
2019-05-31 12:43:05christian.heimes修改状态: open -> closed

抄送: + christian.heimes
消息: + msg344072

resolution: not a bug
stage: resolved
2019-05-31 12:40:18Akilesh K创建