Strip function prototype
Declaration: S is a string, RM is the sequence of characters to be deleted. You can only delete characters or strings that start or end. The middle character or string cannot be deleted.
S.strip (RM) deletes the character at the beginning and end of the s string that is in the RM delete sequence
S.lstrip (RM) deletes the character at the beginning of the S string at the RM delete sequence
S.rstrip (RM) deletes the character at the end of the S string that is in the RM delete sequence
Attention:
1. When RM is empty, the default deletion of whitespace characters (including ' \ n ', ' \ R ', ' \ t ', ')
For example:
2. The RM deletion sequence here is as long as the character on the edge (beginning or end) is deleted in the delete sequence.
For example:
Example:
Split usage of strings
Description
There is no character type in Python, only strings, where the character is a string that contains only one character ...
The split returns a list.
First, a common situation is listed, with no arguments, and the default is white space characters. As follows:
The results are:
1. Divide by one character, as '. '
1 2 3 4 |
str = (' www.google.com ') print str str_split = str. Split ('. ') print Str_split |
The results are as follows:
2. Divide by one character and divide n times. If you press '. ' Split 1 times
1 2 3 4 |
str = (' www.google.com ') print str str_split = |