Python 官方文档:入门教程 => 点击学习
https://blog.csdn.net/langb2014/article/details/54800203 ---------------------------------------------------补充:2018-09-2
https://blog.csdn.net/langb2014/article/details/54800203
---------------------------------------------------
补充:2018-09-24
---------------------------------------------------
Class 中的 def __init__(): 称为构造器/构造方法
super().__init__是调用父类的def __init__():
#!/usr/bin/python
# -*- coding: utf-8 -*-
class A(object):
def __init__(self, por):
self.por = por
print ("por", self.por)
class B(A):
def __init__(self,var):
super(B, self).__init__(var)
b = B(1)
print (b)
print (type(b))
结果:
por 1
<__main__.B object at 0x7ff461949048>
<class 'type'>
--结束END--
本文标题: python Class高级编程:sup
本文链接: https://www.lsjlt.com/news/185933.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0