python
summersunrain
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
方法重写
#方法重写 #如果你的父类方法的功能不能满足你的需求,你可以在子类重写你父类的方法,实例如下: class Parent: def myMethod(self): print("调用父类方法") class Child(Parent): def myMethod(self): print("调用子类方法") c=Child() c.myMet...原创 2018-11-23 17:13:05 · 142 阅读 · 0 评论 -
多继承
#多继承 #若是父类中有相同的方法名,而在子类使用时未指定,python从左至右搜索 即方法在子类中未找到时,从左到右查找父类中是否包含方法。方法名同,默认调用的是在括号中排前的父类的方法 #class people: # name='' # age=0 # _weight=0 # def __init__(self,n,a,w): # self.name...原创 2018-11-23 17:16:19 · 135 阅读 · 0 评论 -
super的用法
class FooParent: def __init__(self): self.parent = 'I\'m the parent.' print ('Parent') def bar(self,message): print ("%s from Parent" % message) class FooChil...转载 2018-11-23 19:04:27 · 773 阅读 · 0 评论 -
斐波那契数列
def fab(n): if n<1: print('输入有误!') return -1 if n==1 or n==2: return 1 else: return fab(n-1)+fab(n-2)原创 2018-11-17 19:34:44 · 146 阅读 · 0 评论 -
python---if--elif--else
if 语句 Python中if语句的一般形式如下所示: if condition_1: statement_block_1 elif condition_2: statement_block_2 else: statement_block_3 如果 "condition_1" 为 True 将执行 "statement_block_1" 块语句 如果 "condition_1" 为Fals...原创 2018-11-17 20:14:26 · 693 阅读 · 0 评论 -
python-while--for
Python中的循环语句有 for 和 while。 Python循环语句的控制结构图如下所示: while 循环 Python中while语句的一般形式: while 判断条件: 语句 #以下实例使用了 while 来计算 1 到 100 的总和: n = 100 sum = 0 counter = 1 while counter <= n: ...原创 2018-11-17 20:50:21 · 202 阅读 · 0 评论
分享