The string in Python is represented by an array, which is similar to the C language (Python is written in C). Because of the character of the string: it is represented by an array of contiguous addresses in memory, so only an exception to the string operation is to open up a piece of memory. So try to use less + connection strings.
If the declaration variable is the same, the address pointing to memory within a certain range is the same. Beyond this range, it is redistributed in memory.
The string comparison = = is the value of the table memory, which is the address of the comparison memory.
String placeholder,%s string,%d number. Format () can also be used. This way you can replace the + connector.
4.1
Name = "Sglsjgjj%s%d"
Name% ("Guo", 100)
4.2
Name = "I am {0}, age {1}"
Name.format ("Guo", 12)
"" "String" "" can represent multiple lines of string.
Name= "Alex" because the string is a character array, name[0]= "a" range: name[0:2]= "Al" Name[0:]= "Alex"
name[-1]= "x" name[:-1]= Ale
Len (name) Gets the length of the string. Name[-1]=name[len (name)-1]
Name.strip () strips the string two spaces Name.lstrip () to remove the left space. Rstrip () Remove the right space.
This article is from the "Runaway Mustang" blog, please be sure to keep this source http://10846992.blog.51cto.com/10836992/1760322
Python learning process-string description