[Natural language processing (a)] - related basic skills

1.python string related operations

= S1 " Hello " 
S2 = " World! " 
# removed string left and right spaces 
S1 = s1.strip () 
S2 = s2.strip ()
 # string concatenation 
S = S1 + S2
 # Find character or substring 
s_index = s .index ( ' Hello ' )
 # string case conversion 
S3 = "the ABC" 
S4 = " ABC " 
s3_lower = s3.lower () 
s4_upper = s4.upper ()
 # flip string 
s_reverse = S [:: -. 1 ]
 #Search string 
s_find s.find = ( " Hello " )
 # split string 
S5 = " A, B, C, D, E " 
s5_split = s5.split ( " ,")
Import Re
 from the Collections Import Counter
 # to obtain the maximum number of characters appears in the string 
DEF count_char (str): 
    str = str.lower () 
    RES = re.findall ( " [az] " , str) 
    COUNT = Counter (RES)
     return [K for K, V in count.items () IF V == max (List (count.values ()))]

2. Regular expressions (many tutorials online, the key is to understand what it means each of which represents, but also to write, in fact, no big deal, do not write here) to only write about is how to use python

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/xiximayou/p/11829706.html