17 lines
558 B
Markdown
17 lines
558 B
Markdown
---
|
||
title: Classes
|
||
localeTitle: 类
|
||
---
|
||
## 类
|
||
|
||
类是创建对象的“蓝图”:编写类允许描述属性和行为公共到该类的每个实例。
|
||
|
||
## 创建一个类
|
||
|
||
要定义类,请使用关键字**类** ,后跟定义类的名称和冒号。以下所有行(描述属性和行为/方法的代码) - 在Python函数中缩进。例如,要创建一个名为Person的类,我们可以编写:
|
||
|
||
`class Person: <code describing attributes and behaviors/methods>`
|
||
|
||
类定义必须在它们产生任何影响之前执行。
|
||
|
||
#### 更多信息: |