News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

Lecture 25: Character conversion, string splitting, and string merging of Python strings

posted on 2023-05-03 20:58     read(613)     comment(0)     like(29)     collect(0)


1. Character conversion of strings

1.1. The concept of character conversion

The string replacement mentioned above is to replace a substring in the string with a new substring. If we want to convert some characters in the string, that is, to convert a single character in the string Replacement can be realized by calling the methods maketrans and translate.

First call the maketrans method to create a conversion table, declare in the conversion table what characters to convert those characters into, and then pass the created conversion table as a parameter to the translate method to realize the conversion of characters.

The syntax of the maketrans method to create a translation table:

str.


Category of website: technical article > Blog

Author:kimi

link:http://www.pythonblackhole.com/blog/article/290/08c5650049a1494b6447/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

29 0
collect article
collected

Comment content: (supports up to 255 characters)