日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:Pythonsuper()

內(nèi)置函數(shù)super()有助于 python 中的繼承。該函數(shù)返回一個表示父類的對象,并允許訪問父類的方法和屬性。

創(chuàng)新互聯(lián)建站服務項目包括三門網(wǎng)站建設、三門網(wǎng)站制作、三門網(wǎng)頁制作以及三門網(wǎng)絡營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關系等,向廣大中小型企業(yè)、政府機構等提供互聯(lián)網(wǎng)行業(yè)的解決方案,三門網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務的客戶以成都為中心已經(jīng)輻射到三門省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!

 **super()** 

超級()參數(shù):

它不需要任何參數(shù)。這個方法可以處理多個繼承,并且它避免了顯式使用基類名稱。

超級()返回值

此方法不返回任何內(nèi)容。在 python 中,方法解析順序(MRO)概述了方法的繼承順序。派生調(diào)用中的方法總是在基類的方法之前調(diào)用。

Python 中super()方法的示例

示例 1:單繼承的super()在 python 中是如何工作的

 class Mammals(object):
  def __init__(self, mammalName):
    print(mammalName, 'is a pet animal.')

class Cat(Mammals):
  def __init__Cat has four legs.')
    super().__init__('Cat')

c = Cat() 

輸出:

Cat is a pet animal.

示例 2:如何在 python 中使用多重繼承的super()

 class Animals:
  def __init__(self, Animals):
    print(Animals, 'is an animal.');

class Mammals(Animals):
  def __init__(self, mammalName):
    print(mammalName, 'is a pet animal.')
    super().__init__(mammalName)

class NonWingedMammal(Mammals):
  def __init__(self, NonWingedMammal):
    print(NonWingedMammal, "can't fly.")
    super().__init__(NonWingedMammal)

class NonMarineMammal(Mammals):
  def __init__(self, NonMarineMammal):
    print(NonMarineMammal, "can't swim.")
    super().__init__(NonMarineMammal)

class Cat(NonMarineMammal, NonWingedMammal):
  def __init__(self):
    print('Cat has 4 legs.');
    super().__init__('Cat')

c = Cat()
print('')
bat = NonMarineMammal('Bat') 

輸出:

Cat has 4 legs.
Cat can't swim.
Cat can't fly.
Cat is a pet animal.
Cat is an animal.

Bat can't swim.
Bat is a pet animal.
Bat is an animal. 

本文題目:創(chuàng)新互聯(lián)Python教程:Pythonsuper()
網(wǎng)站URL:http://www.5511xx.com/article/dpccphs.html