第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
  • # Enter a code

    class Person(object):

    ? ? def __init__(self, name, gender, **kw):

    ? ? ? ? self.name = name

    ? ? ? ? self.gender = gender

    ? ? ? ? for k, v in kw.items():

    ? ? ? ? ? ? setattr(self, k, v)


    p = Person('Bob', 'Male', age=18, course='Python')

    print(p.age)

    print(p.course)

    查看全部
  • xiaohong.name = 'xiaohong'
    xiaohong.sex = 'girl'
    xiaohong.age = 13

    print(xiaohong.name)
    print(xiaohong.sex)
    print(xiaohong.age)
    查看全部
  • xiaohong.age = xiaohong.age + 1
    查看全部
  • class Person(object):? pass xiaohong = Person() xiaoming = Person()
    查看全部
  • class Person(): pass? class Person(object):? pass
    查看全部
  • class Person:? pass
    查看全部
  • 重點(diǎn)

    查看全部
  • li=['bob', 'about', 'Zoo', 'Credit']

    def f (x):
    return li[0]

    l=sorted(li,key=f)
    print(l)
    查看全部
  • li=list(range(1,101))
    print(li)
    def f(x):
    return (x**0.5) % 1 == 0


    for i in filter (f,li):
    print(i)
    查看全部
  • li=['lalice', 'BOB', 'CanDY']

    def f(s):
    return s.capitalize()

    for i in map(f,li):
    l=list(map(f,li))
    print(l)

    查看全部

  • #請參考Student類,編寫Teacher類,老師擁有任教某個科目的屬性。

    class Students:
    def __init__(self, name, gender,score ):
    self.name = name
    self.gender = gender
    self.score = score

    class Taecher (Students):
    def __init__(self,name,gender,score,account):
    super().__init__(name,gender,score)
    self.account=account

    def get_info (self):
    return self.name,self.gender,self.score,self.account
    tt=Taecher("張三","女",90,"語文")

    print(tt.get_info())

    ?
    查看全部
    0 采集 收起 來源:Python繼承類

    2024-10-22

  • #果將類屬性count改為私有屬性__count,則外部無法獲取__count,但是可以通過一個類方法獲取,請編寫類方法獲得__count值。


    class Animal(object):
    __count= 999
    def __init__(self, name, age):
    self.name = name
    self.age = age

    @classmethod
    def set_count (cls, new_count):
    cls.__count=new_count

    @classmethod
    def get_count(cls):
    return cls.__count


    print(Animal.get_count())

    Animal.set_count(9868)
    print(Animal.get_count())


    在類上調(diào)用方法
    查看全部
  • #Animal類的age、name、localtion定義成私有屬性,并定義對應(yīng)的方法修改和獲取他們的值。 class Animal : def __init__(self,name,age,localtion): self.__name=name self.__age=age self.__localtion=localtion def get_name (self): return self.__name def change_name (self,new_name): self.__name=new_name def get_age (self): return self.__age def change_age (self,new_age): self.__age=new_age def get_location (self): return self.__localtion def change_localtion(self,new_localtion): self.__localtion=new_localtion dog=Animal('dog',88,'鄭州') print(dog.get_name(),dog.get_location()) dog.change_localtion('北京') print(dog.get_name(),dog.get_location())
    查看全部
  • # 實(shí)例私有屬性
    class Animal(object):
    ??? def __init__(self, name, age):
    ??????? self.name = name
    ??????? self._age = age

    dog = Animal('wangwang',8)
    print(dog.name) # ==> wangwang
    print(dog._age) # ==> 1#不能從外部訪問私有屬性
    查看全部

  • 請給 Animal類添加一個類屬性 count,每創(chuàng)建一個實(shí)例,count 屬性就加 1,這樣就可以統(tǒng)計(jì)出一共創(chuàng)建了多少個 Animal的實(shí)例。

    class Animal ():
    count =0
    def __init__(self,name,age):
    self.name=name
    self.age=age
    count+=1


    dog= Animal ('dog',2)
    cat= Animal ('cat',6)
    print(dog.name,dog.age)
    print(cat.name,cat.age)
    查看全部
    0 采集 收起 來源:Python類屬性

    2024-10-21

舉報

0/150
提交
取消
課程須知
本課程是Python入門的后續(xù)課程 1、掌握Python編程的基礎(chǔ)知識 2、掌握Python函數(shù)的編寫 3、對面向?qū)ο缶幊逃兴私飧?/dd>
老師告訴你能學(xué)到什么?
1、什么是函數(shù)式編程 2、Python的函數(shù)式編程特點(diǎn) 3、Python的模塊 4、Python面向?qū)ο缶幊?5、Python強(qiáng)大的定制類

微信掃碼,參與3人拼團(tuán)

微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復(fù)購買,感謝您對慕課網(wǎng)的支持!