When using Python, a pit of the Strip () command was found.
The previous understanding of strip (x) is to remove the "x" string that is contained at the beginning and end, if not included, without removing it.
Here's a pit: Python's handling of string x is a set, not a fixed-order string. That is, the X is split into a set of a single letter, and if the string of the Strip () contains any of the characters of that set in the left and right side, it will be strip () dropped. Examples are as follows:
>>> a= "abc_1213" >>> a.strip (' abc_ ') ' 1213 ' >>> a.strip (' ba_c ') ' 1213 ' >>> a.strip ( ' Zxcvbnmasdfghjklpoiuytrewq ') ' _1213 ' >>> a.strip (' zxcvbnmasdfg_hjklpoiuytrewq ') ' 1213 '
In the beginning, the individual's understanding is the first case. Strip (' abc_ ') will only remove the "abc_" to the left.
After the experiment, it is confirmed that the string to be strip is treated as a set. As long as the left and right characters are inside the set, they are removed one at a time until the first character that is not inside the set is encountered.
Traps for strip () in Python