【python】基础-变量和运算符
- python中的变量
每个变量使用前需赋值,赋值后才能创建
等号赋值=
- 等号左边变量名(见名知义)
- 等号右边为变量指向的value
变量名以字母 下划线 数字组成,不能以数字开头,区分大小写
- 大驼峰命名在python中通常用来定义类名
- python中常见的数据类型
-
- int
-
- str
-
- bool
-
- float
var = 'test'
var2 = 123
print(var,var2)
输出:test 123
python内置的关键字不可作为变量名
>>> print(keyword.kwlist)
['False', 'None', 'True', '__peg_parser__', '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']
- 运算符
- 比较运算符
<> == - 逻辑运算符
not and or -
赋值运算符
- 比较运算符

浙公网安备 33010602011771号