Six types of data - String

The string itself is not changed, but it can be indexed / slicing, get a substring; all this does not change the string itself.

 

 python escapes:

 Built-in string as follows:

 

 

 

 

 Among them, the frequent use of built-in functions:

. 1 , and the string of bytes type interconversion

 

 2. Find a string substring

 

 3, the length of string required

 

 

 4, the string case conversion

 

 5, String split

 

6, in order to determine whether the specified character beginning / end of the string.

 

 

 7, to string space

 8, as a string delimiter, connect it to a new string

 Note: Here the os.path.join and () are not the same, the process is a combination of a plurality of paths after the return! ! !

 format () method formatted

 String color control

 The format is:

\ 033 [display; foreground; background color text m \ 033 [0m 

 

 

 

 

 

 

 

 Character Encoding

ASCII code: only 255 characters, each of 8 bits are required i.e. 1 byte

Unicode encoding: Table 2 bytes characters. International organizations to develop the character encoding scheme can accommodate all the world's text and symbols.

UTF-8 encoding: 1 byte English characters, kanji characters represent 3

Note: python3 all use Unicode encoding at runtime! ! !

In addition there are a few rules:

1, the operating system is running, in memory, uniform use Unicode encoding, when it is necessary to save the data to disk or over a network when it is converted to UTF-8 encoding, for storage and transmission.

2, when a text editor, UTF-8 encoded characters read from the file system or the hard disk is converted to Unicode character memory for program or operating system. After editing, save the time and then converted to Unicode UTF-8 is transferred to the customer's browser.

3, when browsing the web, the service area will be dynamically generated content into Unicode UTF-8 is transferred to the customer's browser.

Guess you like

Origin www.cnblogs.com/KeenaCherry/p/11925324.html