测试的自我放逐

迷茫中探索

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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都是什么

 

posted on 2018-05-28 21:57  软测小白6v  阅读(77)  评论(0编辑  收藏  举报