Python Basic Learning Notes (iv)

Source: Internet
Author: User

Variables and strings in Python

Variable:

1. Variable naming rules: Letters, numbers, underscores, cannot start with a number

2, the variable is assigned with the = number

3, the reference of the variable directly using the variable name, no other with the help of other symbols


String:

1, the string to be quoted in single or double quotation marks, and in pairs appear

2. You can use \ to escape special characters

3. Use of raw characters: when you encounter special characters that require multiple escapes, you can use the original character pairs to escape a special character in the entire string. It is simple to use, just precede the string with a character R!

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/88/55/wKioL1fwsOWQu-w8AAAzMBe4fH0312.png-wh_500x0-wm_3 -wmp_4-s_4263867804.png "title=" Rchar.png "alt=" Wkiol1fwsowqu-w8aaazmbe4fh0312.png-wh_50 "/>

But one thing to note is that after using the escape character, the last character cannot be a special character, if a special character is used directly, for error, when there are other workarounds

>>> str = R ' C:\now\david\abc\ '

Syntaxerror:eol while scanning string literal


4, long string: If you need to get a string that spans multiple lines, you can use a long string and a long string with a triple quote string:

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/88/58/wKiom1fwsnKDJ9B9AAA-xUoVARA777.png-wh_500x0-wm_3 -wmp_4-s_1735411117.png "title=" Triquot.png "alt=" Wkiom1fwsnkdj9b9aaa-xuovara777.png-wh_50 "/>

This article is from the "Davidlee's Linux Road" blog, so be sure to keep this source http://davidlinux.blog.51cto.com/5965954/1858385

Python Basic Learning Notes (iv)

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.