# String # In Python, all strings enclosed in quotation marks can be single quotation marks or double quotation marks & quot; thisastring & quot; Python learning _ string of Guibs
# String # In Python, all enclosed in quotation marks are strings. quotation marks can be single quotes or double quotes "This is a string" 'This is also a string' #. Therefore, you can include "or'' I told myself in a string, "you are Gubis" '"The name 'guibs' is my nickname" # specify The first letter in uppercase #[. title ()] name = 'MacBook Pro' print (name. title () # specify all uppercase strings #[. upper ()] print (name. upper () # All lowercase strings #[. lower ()] print (name. lower () # Merge (splice) strings # [use + splice string] first_name = "guibs" last_name = 'G' full _ name = first_name + "" + Last_nameprint (full_name) hello_message = "Hello," + full_name.title () + "! "Print (hello_message) # tab # [\ t] print (" Python ") print (" \ tPython ") # linefeed # [\ n] print (" 123 ") print ("1 \ n2 \ n3") # delete string blank #[. rstrip () delete extra white space at the end of the string] print ("remove unnecessary white space at the end of the string Swift and Python") favorite_language = "Swift and Python" print (favorite_language + "are my favorite ages ") print (favorite_language.rstrip () + "are my favorite ages" + "\ n ")#[. lstrip () delete extra white spaces at the beginning of the string] print ("remove unnecessary white spaces at the beginning of the string Swift and Python") print (favorite_language + "are my favorite ages") print (favorite_language.lstrip () + "are my favorite ages" + "\ n ")#[. strip () removes leading and trailing leading spaces of a string] print ("removes leading and trailing spaces of a string Swift and Python") print (favorite_language + "are my favorite ages") print (favorite_{age.strip () + "are my favorite ages" + "\ n") # correct quotation marks # reserved "" Display print ('I told myself, "you are Gubis "') # retain ''display print (" The name 'guibs 'is my nickname ")
The above is the content of Guibs's Python leart_string. For more information, please follow the PHP Chinese network (www.php1.cn )!