zoukankan      html  css  js  c++  java
  • 学习小结(9)

    1、面向对象

           class Test():     #class来定义类

                  country = 'China'      # 类变量  直接定义在类中的

                  #实例方法  必须实例化才能调用

                  def my(self):      #没有self 相当于静态方法。

                    print(self.country)

           a = Test()    # 类名加()就是实例化 ,其中a是对象也是实例

           print(a.country)

           a.my()

           a.country = 'Jap'  #给a的对象绑定了一个属性。

           print(a.country)

           print(Test.country)

    思考:

           1、总共会print几次

           2、每次print都是什么

  • 相关阅读:
    10 Iterable之遍历Map、Set、Array
    9 Map和Set
    8 循环
    5 字符串
    6 数组
    4 数据类型
    2 变量
    实现简单的邮件收发器(十二)
    10.19 初识django
    10.18 数据库之索引优化方案
  • 原文地址:https://www.cnblogs.com/cslw5566/p/9102516.html
Copyright © 2011-2022 走看看