Python little knowledge + reserved words

note

  • ! / usr / bin / Python # - - Coding: UTF-8 - - # Chinese encoding
  • Python blank line: between a function or class method between separated by empty lines, represents the beginning of a new code
  • Python NOTE: use of single-line comments beginning #, multi-line comments using three single quotation marks ( '' '), or three double quotation marks ( "" ")
  • Python Identifier: letters, numbers, underscores, all identifiers may include English, numbers and underscores (_), but can not begin with a number, the identifier is case sensitive. Identifiers beginning with an underscore have a special significance. _Foo begin single underline represent can not directly access the class attributes, accessed through the interface provided by class, XXX can not be used from> Import introduced. In the private members of class representatives __foo beginning double underlined, is double-underlined start and end of the foo Representative Python in particular specific identification method, such as init constructor () represent the class.
  • The default print output: the new line is, if you want to achieve does not need to wrap variables comma at the end,
  • Python pass: empty statement, in order to maintain the integrity of the program structure. pass without doing anything, generally used as a placeholder statement.
  • Python reserved characters: all Python keywords contain only lowercase letters.
Reserved words Description
and Expressions for calculation, a logical AND operation
as For type conversion
assert Asserted, the variable is determined whether the value of the conditional expression is true or
break Break loop execution
class It is used to define the class
continue The next cycle continues
def Function or method used to define the
of the The value of a variable or deleted sequences
elif Conditional statements, and if, else in combination
else Conditional statement, and if, elif used in combination, and also be used for abnormal loop
except comprising operation code blocks except the catch exceptions, and try, finally combination
exec Python statement for execution
for for loop
finally After the statement abnormality, abnormal, the finally is always executed, the block comprising, and try, except in combination
from Import module for use in conjunction with import
globe Define global variables
if Conditional statements, in conjunction with else, elif
import Module for importing, from the use in combination with
in Determining whether the variable in the sequence
is Determine whether a variable is an instance of a class
lambda Anonymous defined variables
not Expressions for calculation logic NOT operation
or Expressions for calculation, logical OR
pass Empty class, method, function placeholder
print Print statements
raise An exception is thrown operation
return Functions for returning results from
try ry include statements may appear abnormal, and except, finally used in combination
while while the loop
with Python simplified statement
yield The return value from a function so
nonlocal  
false

Guess you like

Origin www.cnblogs.com/wjlyn/p/11543549.html