Basic Python Concepts

Source: Internet
Author: User

Number

There are 4 types of numbers in Python--integers, long integers, floating-point numbers and complex numbers

String

    • Use single quotation marks (')
    • Use double quotation marks (")

Identical to single quote use

    • Use three quotation marks ("' or" ")

Indicates a multi-line string. Single and double quotes are freely available in three quotation marks

Print ("' This is multi-linestring the ' first line, this issecond line    " Double quotation marks can be used "     ' single quotation mark can also be used '       There is also a blank line       below ")

Results:

    • Escape character

In a string, a single backslash at the end of the line \ Indicates that the string continues on the next line instead of starting a new row.

"This is the first sentence.\

This is the second sentence. "

Equivalent to "This is the first sentence." This is the second sentence. "

    • Natural string

Indicates that a specially processed string, such as an escape character, is not required. specified by prefixing the string with R or R. For example R "string\n". Output: string\n

    • Unicode string

Handles text written in languages that contain non-English language. By prefixing the string with U. For example, U "This is a Unicode string".

    • The string is immutable
    • Concatenate strings by literal meaning

If you put two strings next to each other literally, they will be automatically connected by Python. For example ' what\ ' ' Your name? ' will be automatically converted to "What's your name?".

Variable

Python simply assigns a value to a variable when it is used, and does not need to declare or define the data type.

Indent in

whitespace (blank cells and tabs) at the beginning of a logical line is used to determine the indentation level of logical lines, which is used to determine the grouping of statements.

Statements at the same level must have the same indentation, which is called a block.

Excerpt from Python's Concise tutorial Chinese

Basic Python Concepts

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.