Python development _ python keywords

Source: Internet
Author: User

The keywords in python3.3.2 are as follows:

The following identifiers are used as reserved words, orKeywordsOf the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here:

False                                                        nonlocal                                                                                      

A total of 33.

Flase Boolean value, indicating false, opposite to True
Class Define class keywords
Finally

Add an exception when handling the exception. With it, the program always needs to execute the program code block in finally, such:

 MyException(Exception):      
Is  

Id is used to uniquely identify an object. type identifies the object type. value is the object value.
Is determines whether object a is a B object and is determined by id.
= Determines whether the value of object a is equal to the value of object B. It is determined by value.

>>> a = 1>>> b = 1.0>>> a >>> a ==>>>12777000>>>14986000
Return Return statements are used to jump out of a function when a function is returned. We can also return a value from the function.
None

None is a special constant. None and False are different. None is not 0. None is not an empty string. If None is compared with any other data type, False is always returned. None has its own data type NoneType. You can copy None to any variable, but you cannot create other NoneType objects.

>>>< >  >>> None ==>>> None == >>> None ==>>> None ==
Continue The continue statement is used to tell Python to skip the remaining statements in the current loop block and continue the next loop.
For For... in is another loop statement that recursively uses each item in the queue on a series of objects.
Lambda

Anonymous functions are a very fashionable concept, improving the Code's conciseness. For example:

g =  x: x*23)
Try We can use the try... try t statement to handle exceptions. We place the common statements in the try-block and the error handling statement in the Fail T-block.
True Boolean value, indicating true, opposite to False
Def  
(>>> hello,hongten
From Use import or from... import in python to import the corresponding module
Nonlocal The nonlocal keyword is used to use outer (non-Global) variables in functions or other scopes, such;
=+= 1        =(mc())
While The while statement allows you to execute one statement repeatedly. A while statement is an example of a loop statement. The while statement has an optional else clause.
And Logical judgment and C's & same
Del

Del is used for list operations to delete one or more consecutive elements. For example:

a = [-1, 3,, 85]  a[0]  a[2:4] 
Global Defines global variables. For details, refer to global variables and local variables in python _ python.
Not Logical judgment and C! Same
With

With is only available after python2.5. It is essentially a control flow statement. with can be used to simplify try-finally statements. Its main usage is to implement a class _ enter _ () and _ exit _ () methods, such:

 
As Use
Elif Used with if
If The if statement is used to test a condition. if the condition is true, we run a statement (called the if-block). Otherwise, we will process another statement (called the else-block ). Else clauses are optional.
Or Logical judgment is the same as that of C |
Yield Yield is a keyword. It is used like return. yield is telling the program that the function is required to return a generator, for example:
= range(3 i  i*i
Assert

Assertion, this keyword is used to check the correctness of the program during running, and is used in the same way as many other languages. For example:

 len(mylist) >= 1  
Else  
Import

Use import or from... import in python to import the corresponding module, for example:

 sys  *(,path)
Pass

Pass means not to do anything. It is used to make up for conflicts between syntax and empty definition. I understand its benefits are embodied in the Code compiling process, for example, you can write the entire framework of the software first, and then fill in the content of the specific functions and classes in the framework. If no pass compiler is available, a bunch of errors will be reported, making the entire development process not smooth, for example:

 f(arg):      C:        
Break  

The break statement is used to terminate a loop statement, that is, even if the loop condition is not called False or the sequence is not completely recursive, the execution of the loop statement is stopped.
An important note is that if you terminate a for or while LOOP, no corresponding loop else block will be executed.

Except Use the try and retry t statements to capture exceptions.
In For... in is another loop statement that recursively uses each item in the queue on a series of objects.
Raise

Python raise is similar to java throw and throws exceptions. For example:

 MyException(Exception):      
   

 

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.