摘要:
#一个接口,多种实现 #实现接口的重用 class Animal: def __init__(self, name): # Constructor of the class self.name = name def talk(self): # Abstract method, defined by convention only pass... 阅读全文
摘要:
1 继承: 2 #python2 经典类是按深度优先来继承的,新式类是按广度优先来继承的 3 #python3 经典类和新式类都是按广度优先来继承的 4 5 6 7 #经典类:class People: 8 class People(object): #这个是新式类,多继承的时候有了改变 9 10 def __init__(self, name, age): ... 阅读全文
摘要:
from math import sqrt for n in range(99, 82, -1): root = sqrt(n) if root == int(root): print(n) break else: #发现这个else只有在break不执行的时候执行。这个是循环的else子句 print("Didn't find the ... 阅读全文
摘要:
#! /usr/bin/env python # -*- coding:utf-8 -*- # Author linux ku class Dog(): def __init__(self, name): self.name = name def bulk(self): print("%s : Wang wang wang!"%self.na... 阅读全文