Python Learning Path (i)

Source: Internet
Author: User

Written in front: Most people will end up living a mediocre life short, I use Python

Chicken soup: Travel Around the world, Tesla sports car feel a different life

Introduction

About Python Cpython Jpython ... The byte-code import module automatically compiles the module. Py into bytecode. PYc Python2 differs from 3

Python preprocessing command #/usr/bin/env python #-*-coding:utf-8-*-under Linux under Windows

Pycharm: Font font size selection interpreter select git using code to edit template usage

Python encoding GBK Unicode utf-8 Windows command line GBK

Unequal Unicode precedence between Python2 Kanji decode (utf-8)------converted to Unicode-----encode (GBK) encoding

Equality between Python3 Chinese character direct encode (GBK) encoding

One, operator

+ - * / // %

In does not determine whether the character is in the list of elements in the string

And Or not

Ii. Basic flow of control

(1) Conditional statements

If condition: else:

If condition: Elif condition: Elif Condition: Else:

(2) Loop statement

While condition: Resume loop when condition is met

Break jumps out of the loop this usage can ignore unnecessary actions after break when the condition is written directly to the loop condition

Continue skip this cycle and continue the Next loop implementation 1 2 3 4 7 8 9 Skipping (interval) for some continuous loop operations

Exercise: Output Even, odd, 1-100, and output 1-100 in multiples of 7

Iii. python basic data types

int number

str character type

BOOL Boolean Boolean is the first to realize that the light and dark sequence of a lamp can represent the information of a person binary representation of the Beacon Tower discussion binary represents 0-9 consecutive numbers

List lists

Tuple tuples

Dict Dictionary

These data types are a class, the class is a template, the specific data is an object (instance) of the corresponding class, it belongs to this class, owns the method of this class (template).

CTRL +/Bulk Comment

Type (temp) gets variable types

Dir (temp) lists all function methods for variables

Details of the Help (type (temp) method)

STR, UPPER () hold down CTRL, the left mouse button click to locate the corresponding library, function

Analogy: You are the Defender (object) back to the Castle (library) Take the tool (method), the defenders belonging to this castle have the same (similar) method, the newly added soldier (Declaration of the new instance) need to conform to the rules of the castle, have the corresponding right

Object-oriented originates from biologists ' inheritance, polymorphism

(1) Int integer

A. +-*/%//

The underlined method is a special built-in method, such as the plus sign (+), which is actually the __add__ method in int

B. Obtaining the BITS length

Bit_length () bit length in binary notation there are several

The method in parentheses () represents the parameter, and the method can be used to find out how many parameters the method can pass, what the default parameter is

(2) String str

A. Center String Content Center Center (string, "*") ******string******

B. Count lookup count ("Al", 0, 4) Find statistics Al has appeared several times within 0 to 4

C. Endwith to ... End to specify range

D. Expandtabs Change the TAB key to a space \ t ====> space

E. Find lookup string returns character position not found return-1

F. Format formatted output

string = "Hello {0}, age {1}"

Print (s)

New1 = S.format ("Alex", 19)

Print (New1)

G. Index returned index could not find an error

Python Learning Path (i)

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.