Python Basics-high-speed transformation: strings

Source: Internet
Author: User

A python string is worth saying.

Look first:

>>>"Hello world!"‘Hello world!‘

We write a double-quote, but after printing it is a single quote.

What's the difference?

The answer is that there is no difference between the single and double cited .

>>>‘Let‘s go!‘

The above code is wrong, assuming that the string itself includes a single argument, then use the double-cited
Identical, assuming that the string itself has a double argument. Then you need to use a single citation .

Then the question comes again. What if a string includes both a single and double-cited arguments?
Need to be escaped :

\"I\‘m OK\".‘

Stitching strings:

>>>"Let‘s Say"  ‘"Hello, world!"‘‘Let\‘s Say "Hello, world!"‘

Write two strings in a row. Python will be stitched together!

Long String
Enclosed in three-lead, it is possible to cross the line:

print‘‘‘This is avery verylong long string!‘‘‘

Raw String
Forbidden Escape, original string has R start !

printr‘\(~_~)/ \(~_~)/‘

Unicode string
Use the U prefix to represent a Unicode string

printu‘汉字‘

Python Basics-high-speed transformation: strings

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.