In Python, the string becomes a powerful set of processing tools, and he is immutable, meaning that the string contains the order of characters and characters, which he cannot modify
The string is a slightly larger category of objects that we need to learn later-the first representation of a sequence
In the section of the string about the operation of the sequence, the following list is the same as the tuple
Some of the operations and functions commonly used in strings
Operation |
Explain |
S= " |
Empty string |
s= "ABC ' d" |
Double quotes and single quotes are the same |
s= ' abc\n ' |
Escape sequences, use variables to fully display characters, Only use the print function to show escape |
S= "" "AAAAA" "" |
Sanchong Quote String block |
S=r ' \temp\spam ' |
Raw string |
S=b ' abc ' |
Python 3.x byte string |
S=u ' BAC ' |
Unicode string |
S1+s2 |
Merge |
S*3 |
Repeat |
S[i] |
Index |
S[I:J] |
Sharding |
Len (s) |
Request length |
"A%s parrot"% kind |
String formatting expressions |
"A {0} parrot". Format (Kind) |
Method of String formatting |
S.find (' xxx ') |
Search |
S.rstrip () |
Remove spaces |
S.replace (' xxx ', ' xxx ') |
Replace |
S.endswith (' xxx ') |
End With XXX |
' xxx '. Join (Strlist) |
Entry and exit separators |
S.encode (' latin-1 ') |
Change code |
For x in S:print (x) |
Iteration |
' xxx ' in S |
Member relationships |
[C*2 for C in S] |
Member relationships |
Map (ord,s) |
Member relationships |
Right here, thank you.
------------------------------------------------------------------
Click to jump 0 basic python-Catalogue
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 Fundamentals python-7.1 String Introduction and common functions in Python