跳转到内容

搜索仅适用于生产版本。 尝试构建并预览网站以在本地测试。

Python 基础速记

  • 只能由:字母、数字、下划线组成

  • 不能以数字开头

  • 不能用 Python 关键字

  • 区分大小写

不可变类型:int、float、str

可变类型:list、dict、set、

x := 10
  • 把 10 赋值给 x
  • 整个表达式的结果也是 10

经典场景

while chunk := file.read(1024):
print(chunk)

相当于

while True:
chunk = file.read(1024)
if not chunk:
break
print(chunk)