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.

Title: lstrip 处理出现bug
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, eryksun, wsqat
Priority: normal Keywords:

Created on 2020-11-18 10:13 by wsqat, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg381323 - (view) Author: sagewang (wsqat) Date: 2020-11-18 10:13
>>> "prefix_prj_t_suffix".strip().lstrip('prefix_prj_').rstrip('_suffix')
>>> "data_prj_t_suffix".strip().lstrip('data_prj_').rstrip('_suffix')
msg381324 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-11-18 10:17
The methods works as designed and documented. The arguments to str.strip, lstrip, and rstrip methods are not prefixes / suffixes. They are sets of characters.

>>> "bad".lstrip("ab")
msg381344 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2020-11-18 14:23
Python 3.9 added str.removeprefix() and str.removesuffix() [1]:

    >>> "data_prj_t_suffix".removeprefix('data_prj_').removesuffix('_suffix')

Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86563
2020-11-18 14:23:15eryksunsetnosy: + eryksun
messages: + msg381344
2020-11-18 10:17:12christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg381324

resolution: not a bug
stage: resolved
2020-11-18 10:13:31wsqatcreate