Question 19: How to get rid of unwanted characters in the string 19 question: how to remove the unwanted characters in the string Python: delete characters in a string

Question 19: How to get rid of unwanted characters in the string

 

Case I: filter blank characters;

Case II: filter \ r character;

Case 3: remove text unicode character combination: phonetic tones;

 

# Specific implementation, participate: P ython: delete characters in a string

 

Program: string strip (), lstrip (), rstrip () method to remove the character string ends;

Option II: microtome + splicing manner, a single fixed position of the deleted character;

Program III: replace string () method, or the re.sub regex (), delete any position of a character;

Option 4: string translate () method, you can delete many different characters at the same time;

Case I: filter blank characters;

Case II: filter \ r character;

Case 3: remove text unicode character combination: phonetic tones;

 

# Specific implementation, participate: P ython: delete characters in a string

 

Program: string strip (), lstrip (), rstrip () method to remove the character string ends;

Option II: microtome + splicing manner, a single fixed position of the deleted character;

Program III: replace string () method, or the re.sub regex (), delete any position of a character;

Option 4: string translate () method, you can delete many different characters at the same time;

Guess you like

Origin www.cnblogs.com/valorchang/p/11434560.html