Python leart_string for Guibs

Source: Internet
Author: User
# 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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.