The function of three quotes in Python (two-point summary of commas)

Source: Internet
Author: User

Three quotation marks

1, three quotation marks: in the program I use # to make a single-line comment, you can use three quotation marks can be a long line of comments.

Three quotation marks can contain multiple lines of string, and often appear in the next line of function declaration, to annotate function, the difference is that this annotation as a default property of the function, can be accessed by the name of the functions. __doc__


2, three-quote formatted output: When printing a string with print, the three quotation marks contain multiple lines of string, the original format output


In [2]: Print "" "...: Hello world ...: My name is Dayun ...: I love you ...:" "" Hello World My Nam E is Dayuni love you


Comma


1. When printing string variables


In [3]: name = ' Dayun ' in [4]: print ' My name is ', Namemy name is Dayun


Of course we can also print with formatted output


In [5]: print ' My name is%s '%namemy name is Dayun


2, the print is appended with a comma (comma), so that print will not output a new line character and end the line to go to the next line.

Name = "Dayun" age = print "My name was%s"% name, print "I ' m%d years of age"% age


Operation Result:


~ Python test.py My name is Dayun I ' m, years of age


Two print printed results on the same line.


This article is from the "Xiaoliuer" blog, make sure to keep this source http://xiaoliuer.blog.51cto.com/11859529/1892281

The function of three quotes in Python (two-point summary of commas)

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.