前言
写一下python相关知识点,巩固基础,也便于以后查缺补漏,与君共勉
常用关键字符
在python中,关键字符和符号指语言中有特殊意义的字符,表示操作,定义结构等特定表示
注释
单行注释:#开始
多行注释:三引号(‘’’ 或"“”)添加到注释收尾
更多注释方式可以考虑注解Annotation或者有更丰富的注释功能的第三方库如pydoc、Sphinx等
35个关键字
print(keyword.kwlist) 可查询关键字列表
[‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘async’, ‘await’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]
1.False、 True(布尔变量)
2.and、or、not(逻辑运算符)
3.if、elif、else(条件语句)
4.for、while(循环语句)continue、break(循环控制)
5.try、except、finally、raise(可能异常代码执行和处理)
6.import、from、as(模块导入)
7.def、return(函数)class(类)lambda(匿名函数)
8.in、is(判断语句)
9.assert(测试代码)
10.with(文件处理)
11.pass(代码占位符)