Python variable definitions and strings

Source: Internet
Author: User
Variable
When a value is assigned to a name, it is stored in memory
Firest = 3
Second = 8
Third = first + second
Print (third)
11

The use of variables requires attention:
1, before use, need to assign value to its first
2. Variable names can include letters, numbers, underscores, but cannot start with a number
3, the letter can make uppercase or lowercase, but the case is different
4, equal sign (=), the left is the name, the right is the value

String
The string is everything inside the quotation marks, the single double quotation mark does not stipulate
Cases:
5 + 8→13
' 5 ' + ' 8 ' →58.

What about single or double quotes in a string?
1. Escape symbol \ Escape the quotation marks in the string
Let ' s go→ ' let\ ' s go! ’

Raw string
Just put an English letter R in front of the string to
Cases:
str = ' C:\now '
Print (str)
C:
ow

str = R ' C:\now '
Print (str)
C:\now

Long string
Sanchong Quote String
Cases:
str = "" "Ah Ah ah Ah
No, no, no, no.
Ah, a quack. 1 ....
"""
Print (str)
Oh, ah, yes.
No, no, no, no.
Ah, a quack. 1 ...

Python variable definitions and strings

Related Article

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.