Python 基础速记
-
只能由:字母、数字、下划线组成
-
不能以数字开头
-
不能用 Python 关键字
-
区分大小写
不可变类型:int、float、str
可变类型:list、dict、set、
海象运算符(3.8+)
Section titled “海象运算符(3.8+)”x := 10- 把
10赋值给x - 整个表达式的结果也是
10
经典场景
while chunk := file.read(1024): print(chunk)相当于
while True: chunk = file.read(1024) if not chunk: break print(chunk)