python basic data types and function key command string -2-

1、join 

1  # string with each character in the specified delimiter split 
2  # are required for the separator 
. 3  
. 4 A = " fat fart pig smell " 
. 5 B = " _ " .join (A)
 . 6  Print (B)
 . 7  
. 8 B = fat fart _ _ _ smelly pig

 

2、split

1  # string is divided in accordance with the specified parameters (parameters not specified reserved) 
2  # Specify partition parameter 
3  # can select a specified number of division 
. 4 A = " abcbcdcde " 
. 5 B = a.split ( ' C ' , 2 )
 . 6  Print (B)
 . 7  
. 8 B = [ ' ab & ' , ' B ' , ' dcde ' ]

 

3、find

1  # from the beginning to find to find and acquire its first position (if the sequence is not present in the output string -1) 
2 A = " ABCABCABC " 
. 3 B = a.find ( ' CA ' )
 . 4  Print (B)
 . 5  
. 6 B =. 3

 

4、strip

1  # to remove the character string specified (the default is not input space) 
2 A = " abcbcbc " 
. 3 B = a.strip ( ' BC ' )
 . 4  Print (B)
 . 5  
. 6 B = A

 

5、upper

1  # string all uppercase letters 
2 A = " Abc " 
. 3 B = A.upper ()
 . 4  Print (B)
 . 5  
. 6 B = the ABC

 

6、lower

1  # all lowercase letters (letters only) 
2 A = " the ABC " 
. 3 B = a.lower ()
 . 4  Print (B)
 . 5  
. 6 B = ABC

 

Guess you like

Origin www.cnblogs.com/chouchouzhu/p/10990610.html