python string type introduced

A. Wording string
1. Single or double quotes
two. Will not change the string
1. The string does not change, then only the new assignment
A = 'the ABC'
B = A
A = 'the XYZ'
print (b)
the result was ABC
three splicing string
1 with a plus sign +
2 is not added to the numeric string type, it is necessary to use the built-in str () function converts the digital type and then spliced into a string type
IV. character common method string
1.title ()
string inside English words (separated by a space called a word) becomes the first letter capitalized, other characters unchanged
2.upper ()
string inside all uppercase English characters change, other characters intact
3.lower ()
string inside all the English characters to lower case, other characters unchanged
4.rstrip (chars)
the rstrip (chars) method on the right sequence for a specific character string truncated (which may be a character may be a character string), the default character for all null characters, including spaces, linefeed (\ n-), tab (\ t) and the like, if a particular parameter represents the end of the sequence of characters to delete
5.lstrip (chars)
after lstrip (chars) method is used to cut off the left space or the specified character string generated New string
6.strip (chars)
method for removing head and tail of the specified character string (line feed spaces or default) or sequence of characters
V. escape character string, tab, newline
1. escape character (), by \ "expressed" by \ represents \
2. tab (\ T), representing four spaces
3. linefeed (\ n), Print will wrap, so \ n generally not on the end of the string, \ n \ t newline indented four spaces

Guess you like

Origin blog.51cto.com/xlazj/2440037