Python single quote, double quotation mark, triple quote difference

Source: Internet
Author: User
1. Both single and double quote usages are the same, but if you have the same characters in a string, you use \ to escape

Example:
1) print ' Hello '
2) print "Hello"
1 and 2, and the result is hello.

3) print ' hell\ ' o '
4) print "Hell ' o"
3 and 4, the result is Hell ' O

5) print ' Hell ' o '
6) print "Hell\" O "
5 and 6, the result is Hell "O

2. Three quotation marks differ from them: "WYSIWYG", which is more intuitive to use when quoting a string in HTML or XML format (it is necessary to escape with single or double quotation marks at this point)
Such as:
Print ""
Hello
World
‘‘‘
The result is
Hello
World


Transferred from: https://zhidao.baidu.com/question/560517703879726724.html

Python single quote, double quotation mark, triple quote difference

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.