程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[learn Python from simple to profound] Python reserved words

編輯:Python

One 、 Introduce

Python The reserved word of is the keyword , Is an identifier defined internally by the programming language and reserved for use . These reserved words cannot be used as constants or variables , Or any other identifier name .

Two 、Python 33 A reserved word

and For expression operations , Logic and operation

as For type conversion

assert Assertion , Used to determine whether the value of a variable or conditional expression is true

break Interrupts the execution of loop statements

class Used to define a class

continue Continue with next cycle

def Used to define functions or methods

del Delete the value of a variable or sequence

elif Conditional statements And if else Use a combination of

else Conditional statements Conditional statements , And if,elif Use a combination of . It can also be used for exceptions and recycling

except Including the operation code after catching the exception , And try,finally Use a combination of

exec Used to perform python sentence

for Loop statement

finally For exception statements , After exception , Always carry out finally Contains code blocks . And try,except Use a combination of

from For importing modules , And import Use a combination of

global Define global variables

if Conditional statements , And else,elif Use a combination of

import For importing modules , And from Use a combination of

in Determine whether the variable exists in the sequence

is Determine whether the variable is an instance of a class

lambda Defining anonymous functions

not For expression operations , Logic is not an operation

or For expression operations , Logic or operation

pass Empty class , function , Placeholder for method

print Print statement

raise Exception throw operation

return Used to return calculated results from a function

try Contains statements that may have exceptions , And except,finally Use a combination of

while Loop statement

with simplify Python The sentence of

yield Used to return values from a function in turn


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved