Python Learning Record: Basic knowledge 1

Source: Internet
Author: User

1. Python physical implementation.

IronPython: driven by Microsoft and driven by DRL Dynamic Language. No common Python third-party class libraries are supported. Latest Version: 2.7. Under study.

CPython: standard version.

StackLess: unlimited stack version.

JPython: Based on Java, WAS is used as a configuration file (indeed, it is very useful ). I heard that there is a Django version.

 

2. Python compares the syntactic sugar of other static languages.

Supported keywords: and (&) or (|) not (!)

3 <4 and 4 <5 abbreviation 3 <4 <5

Value assignment statements ++ and --

Python supports the int long bool float complex (negative) decimal Integer type in 6 by default.

Decimal is used to support 1.1 and decimal. Decimal ('1. 1') is 1.10000001.

 

String slicing:

Pystr = 'geewu hello world'

Pystr [0]

Pystr [2: 5]

Pystr [: 2]

Pystr [3:]

Pystr [-1] The last letter

Pystr [:-2] pystr [start: end: Step]

 

Built-in list and metadata, as well as dictionaries

List aList = [123123,] tuple = (,) the dictionary aDist = {"hello1": '20140901'} cannot be modified '};

 

For Loop + range () built-in Function

For item in [1, 2, 3] is equivalent to for item in range (1, 3)

 

Enumerate () method

Foo = 'abc'

For I in range (len (foo): equivalent to for I, ch in enumerate (foo ):

Print foo [I], '(% d)' % I print ch, '(% d)' % I

 

List Parsing

Squared = [x ** 2 for x in range (4)]

For I in squared:

Print I

Squared = [x ** 2 for x in range (4) if not x % 2]

For I in squared:

Print I

 

Special continuation symbol (\)

# Check Condition

If (weather_is_hot = 1) and \

(Shark_warning = 0 ):

Send_goto_beach_mesg_to_pager ()

Function iskeyword () for determining special keywords ()

 

Common Tools

Debugger: PDB.

RECORDER: logging.

Performance tester: profile, hostshot, cprofile

 

 

Python built-in object.

The default value is none. The Boolean value is always false.

Are all false objects.

None, False, all 0 values, 0, 0.0, 0L, 0.0 + 0.0j, ''," ", [], (), {}

 

Id () obtains the location of the declared variable. a is B is equivalent to id (a) = id (B)

If type (num) is types. IntType

 

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.