Python基础 · 免费预览

类与对象进阶

区分类状态与实例状态,用 property 守护属性,实现 dunder 方法,并用 dataclass 削减样板代码。

1. Overview

Overview

2. Class Attributes vs Instance Attributes

Class Attributes vs Instance Attributes

3. Guarding Values with Properties

Guarding Values with Properties

4. Dunder Methods

Dunder Methods

5. Dataclasses

Dataclasses

6. A Validated Temperature

A Validated Temperature

7. A Dataclass Inventory

A Dataclass Inventory

进入交互式练习

免费注册 · 即时批改 · 自动安排间隔复习。

免费开始这门课