First day of Python

Source: Internet
Author: User

1. Basic knowledge Basic Course List Python basic 7weeks

Data type, Process control, common modules

Functions, Iterators, adorners

Object oriented

Network related part programming 4~5weeks

Socket programming

Producer Consumer Model

The development of the audit Fortress machine system, wcgi Web Foundation development

Algorithms and Design Patterns

Bubbling, binary tree, linked list, hash and graph

Py Web Framework

Mvc,django and flask, Rights management development

2. Python basics Specify a python system interpreter

Depending on the operating system, Windows and Linux specify the system interpreter in a different way. Windows, you need to associate the. py extension file with the Python program, and then add Python to the environment variable. In Linux, in addition to adding Python to the system variables, you need to declare the location of the interpreter used in the first line of the py file.

#!/usr/bin/env Python3

#!/usr/bin/python3

Both of these can be written. The first one uses Env to parse Python3, which requires the user to determine the system command env Python3 can start the Python interpreter normally. The second command is hard code the execution path of the Python interpreter. Depending on the environment, you can specify flexibly.

Variable

A section that stores data in memory. Variables provide intermediate results or intermediate states for program execution, so that other code or procedure calls. All variables must be defined before they are called. When a variable name contains more than one word, it is separated by an underscore, the variable cannot begin with a number, and cannot include special characters. All-uppercase variables are typically used to represent constants.

Day_of_this_year = 213

Year = 2016

The name of the variable

Any operation should have meaning. The budget represents a logical process that should not be used as a direct substitute for a variable unless necessary. The following example is an example of a three-day income statistic. The left side of the operation is meaningful, and the right side of the operation, strictly speaking, just calculate the numerical operation.

Day1 = 400

Day2 = 350

Day3 = 255

Total = day1 + Day2 + day3

A = 400

b = 350

c = 255

m = a + B + C

Hints for output

The Print command can accept multiple parameters, which is said in the Python prompt:

Print (value, ..., sep= ', end= ' \ n ', File=sys.stdout, Flush=false)

If you want to output a message with a hint, you can do this:

Print (' Your input message is: ', your_input)
Character

Character sets are the only way to display characters using a computer. The standard ASCII character set includes 127 characters, including special characters and English letters, as well as numbers. The GB2312 character set is produced by mapping between tables. Different countries have their own, ASCII-based, inter-table mapping character sets. Then, by extension, the GBK large character set is published separately, which is called the ANSI character system in Windows, including 21,886 Chinese characters. The GB18030 character set, including 27,484 characters, is obtained after two expansions. Become a national mandatory standard. Both GB2312,GBK and GB18030 are double-byte character sets, 2bytes,16bit.

In order to achieve the unification of all character sets, human developed the Unicode character system, 4bytes,32bit length, which can display all human text. However, due to the excessive amount of information redundancy, Unicode is reduced to utf-16 and utf-8 two sets of independent systems. utf-16, fixed-length character set system, display with 2bytes,16bit; utf-8, variable-length character set system, English characters according to ASCII storage, Chinese 3Bytes, Latin character 2Bytes.

String

A single or double quotation mark, or a string, consisting of a multi-line string, or a triple single or double quotation mark. Multi-line strings can display multiple \ n information.

input-Basic User interaction
Input ([prompt]), string

Input can output a string of strings as a hint, ending the input with \ n. Therefore, the user can enter a space, which needs to be noted.

Concatenation of strings

Strings can be spliced by the ' + ' operation. When a variable that requires a string is merged, it can be occupied with% and populated by tuples:

' String1 is%s and string2 is%s '% (string1, string2)
Process Control

In Python, the indentation of the same level of code must be consistent, a space, a tab, or four spaces are OK.

If condition:

Working something

Else

Working something

Type () to see the types of the current object, Isinstance () is used to test the type.

First day of Python

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.