我们需要关键字class来定义类

class 类名:
    # 类中定义的内容

比如我们定义一个表示学生的Student类:

class Student:
    pass

说明:

  1. class 后面紧跟类名. 类名的命名使用驼峰命名法.

  2. 类名的后面跟一个冒号

  3. 然后是带有正确缩进的类的主体.(上面的例子中使用 pass, 表示空的类主体)

Copyright © 李振超 2018 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-02-25 07:12:09

results matching ""

    No results matching ""