python super函数

# !/usr/bin/env python
# -*- coding: utf-8 -*-
class AddrBookEntry(object):  ##类定义
    def __init__(self, a, b):  ##定义构造器
        self.var1 = a + 9.1
        self.var2 = b + 11.3

    def updatePhone(self, num):  # 定义方法
        self.var3 = num + str(100)
        return self.var3


class EmplAddrBookEntry(AddrBookEntry):
    def __init__(self, x, y):
        # 调用父类构造函数
        super(EmplAddrBookEntry, self).__init__(123, 456)


a = EmplAddrBookEntry(11, 22)
for x in (dir(a)):
  print(x)
print(a.var1)

C:\Users\TLCB\AppData\Local\Programs\Python\Python36\python.exe C:/Users/TLCB/PycharmProjects/untitled2/ebpf/a1.py

updatePhone
var1
var2
132.1

Process finished with exit code 0
 

你可能感兴趣的:(python,高级编程,python,开发语言)