Python3 Basics of Getting Started

Source: Internet
Author: User
Tags natural string

1. View Python version

Python-v

2. Specify the encoding format for Python files

#-*-Coding:utf-8-*-

3. The variable name begins with a letter and an underscore (_)

_num num

4. Comment # begins with a comment on the line

# Here is the comment section

5, multi-line statement with backslash (\) Implementation

Toatl = Num1 + \

Num2 + \

Num3

6. Data type: Number (integer, Boolean, floating-point, plural), string (string), List (list []), tuple (tuple ()), sets (set {}), Dictionary (dictionary)

Number: Integer (1), floating-point number (1.23), complex number (1+2J)

String: element cannot be changed, can be sliced

List: Elements can be changed, can be sliced

Tuple: element cannot be changed, can be sliced, a tuple containing an element should be followed by a comma, such as Tup = (1,)

Set: unordered non-repeating element sequence, creating an empty collection must set () instead of {}

Dictionary: Unordered key (key): value pairs the set, key (key) is immutable type, create empty dictionary with {}

7. String

Single and double quotation marks for single-line strings (using the same)

Specify multiple lines of string between three quotation marks ("' or" ")

Natural string, preceded by the string R or r,r "Hello World \ n", will not be escaped and displayed as Hello World \ n

8, the same line shows more than one statement, separated by a semicolon (;) between statements

x = 3; y = 4

9. Data type conversion

Returns a new object as a function name, simple as int (x), float (x), str (x), etc.

Python3 Basics of Getting Started

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.