Python Quick Start

Source: Internet
Author: User
Tags python script

(1) Program output: Using the print statement, you can print the content directly or print the value of the variable, instance

(2) Program input: Use the Raw_input () built-in function to read the standard input and assign a value to the specified variable, instance

(3) Note: Python uses ' # ' to mark comments, beginning with ' # ' until the end of the line is a comment, such as print ' Hello ' # another comment, results only print out the Hello

(4) Operator: +-*///% * * < <= > >= = = = <> and Or not Instance

(5) Variable: Assigning a value to a variable name, such as counter = 12, means assigning 12 to a variable of counter

(6) Data type: Includes value, string, list, tuple, dictionary

(7) Code blocks and indents: code blocks are indented to express code logic, typically using 4 spaces to indent

(8) Process Control statement: if and for

(9) List resolution: List resolution You can use a for loop in a row to put all the values into a list, instance

(10) File: Python Opens the file with open (), can be specified as read-only (R), write (W), append (a) Three ways to open, such as handle = Open (file_name, Access_mode = ' R '), if Open () succeeds, A file object handle is returned, and subsequent operations on the file must be done through a file handle, such as accessing the file with the read (), ReadLines () method, and closing the file with the close () method.

(11) Errors and Exceptions: Handling exceptions with the try-except statement, when executing a python statement error, the Python interpreter throws an exception and displays the details of the exception.

(12) Function: A function is a statement group that completes a particular function, and defines the format of the function as "def Function name ():", calling the function "function name ()"

(13) Class: Classes combine the required variables and functions, which are called "encapsulation," which defines a class as the process of encapsulation, and defines the class format as "Class name ():"

(14) Module: A module can perform a specific function, a Python script can be referred to as a module, import the module with an import

(15) Package: Python modules can be organized as a package, which is a collection of modules

Python Quick Start

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.