zoukankan      html  css  js  c++  java
  • 廖雪峰老师的python教程中的几个学习笔记的备份

    首先是学习@property的笔记

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Time    : 2017/5/14 22:18
    # @Author  : 15407_000
    # @Site    : 
    # @File    : 使用@property.py
    # @Software: PyCharm
    
    class student(object):
        score=10
        def getscore(self):
            return self.score
    
        def setscore(self,value):
            if not isinstance(value,int):
                raise ValueError("score must be int")
            if value <0 or value>100:
                raise ValueError("score must be 0~100")
            self.score=value
            pass
        pass
    
    s=student()
    s.setscore(60)
    print(s.getscore())
    s.setscore(1111)

    然后是学习多重继承的:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Time    : 2017/6/6 21:50
    # @Author  : 15407_000
    # @Site    : 
    # @File    : 多重继承.py
    # @Software: PyCharm
    
    class A(object):
        def Run(self):
            print("A runs")
    class B(object):
        def Run(self):
            print("B runs")
    class C(B,A):#这里C类继承了A,也继承了B,但是调用的是B类的run方法。
        '''
        #但是如果是这样继承的:
        class c(A,B):
            pass
        那么调用run的时候会用A的run方法,而不是B的
        '''
        pass
    x=C()
    x.Run()
  • 相关阅读:
    HDU 3466(01背包变种
    HDU 2639(01背包第K大)
    POJ 2184(01背包)(负体积)
    UVA 562(01背包)
    UVA 624(01背包记录路径)
    SQL总结二
    oracle--知识点汇总1
    时间日期----java
    字符串、数值----转换
    字符串反转----示例
  • 原文地址:https://www.cnblogs.com/big-bozi/p/6953927.html
Copyright © 2011-2022 走看看