1. Strip () function
Strip () is the deletion of the characters inside the ' () ', and when () is empty, the default is to remove the whitespace (including ' \ n ', ' \ R ', ' \ t ', ')
(1) S.strip (RM) Remove the characters from the beginning and end of the s string in the RM delete sequence
(2) S.lstrip (RM) Delete the character at the beginning of the S string in the RM delete sequence
(3) S.rstrip (RM) Delete the character at the end of the s string in the RM delete sequence
2. Split function
Split is a split function that splits a string into a "character" and is saved in a list.
1 a='a b c d'2 b=a.split ()3print(b)
Output: [' A ', ' B ', ' C ', ' d ']
The default is a space split with no parameters. The reason for the "character" of double quotes, because the actual Python does not have characters.
Split with parameters according to actual requirements
1 ' www.baidu.com ' 2 B = a.split ('. ' )3print(b)
Output: [' www ', ' Baidu ', ' com ']
You can also take a number parameter, which means "cut a few knives"
1 ' www.baidu.com ' 2 B = a.split ('. ', 1)# with. Cut 1 knives, divided into 2 pieces 3print(b)
Output: [' www ', ' baidu.com ']
Python:strip (), Split ()