freeCodeCamp/guide/chinese/python/object-oriented-programming/classes/index.md

17 lines
558 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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