Python's summary of strings (in)

7. Use [] to extract characters

***There are two extraction methods: forward search; reverse search.
Forward search: the first character on the left, offset 0, the second offset 1, and so on, until len(str)-1.
Reverse search: the first character on the far right, offset -1, second offset -2, and so on, until -len(str).
***Insert picture description here

8. Variable string and string replacement

String replacement raplace()
variable string io.StringIO()

Insert picture description here

9. The slice of the string slice()

The so-called slicing of the string, as the name implies, is to cut the string and take the substring
[start offset start: end offset: step]

Insert picture description here

10.split() function and join() function

split(): The string can be divided into multiple substrings (in the storage list) based on the specified separator. If not specified, the default is a blank character.
The join() function is opposite to the split() function. The join function is used to add a series of substrings.

Insert picture description here

11. String resides

String residency: Only save a copy of the same immutable string, different values ​​are stored in the string residency pool.
Strings (only underscores—, letters, and numbers) will be enabled. stay

Insert picture description here

12.in/not in judge whether a substring belongs to a large string

Insert picture description here

Guess you like

Origin blog.csdn.net/zjdzka/article/details/109203309