亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
L = ['bob', 'about', 'Zoo', 'Credit']

sorted(L, key = lambda i:i[0].upper())
# Enter a code
class animals:
def Setname(self,name):
self.name = name
print('{}'.format(self.name))

dog = animals()
dog.Setname('dog')
cat = animals()
cat.Setname('cat')
class Animal(object):
def __init__(self, name, age, localtion):
self.__name = name
self.__age = age
self.__localtion = localtion

def a(self):
return self.__name,self.__age ,self.__localtion

dog = Animal('wangwang', 1, 'GuangDong')
print(dog.a())
def calc_prod(list_):
def num_prod():
def product(x, y):
return x * y
return str(reduce(product, list_))
return num_prod
L = calc_prod([1,2,3,4,5])
print(L)
print(L())
1、子類定義的時候,需要在括號內寫明繼承的類;
2、在__init__()方法,需要調用super(Student, self).__init__(name, gender),來初始化從父類繼承過來的屬性;
localtion寫錯了,應該是location
# Enter a code
class Animal(object):
count = 0
def __init__(self,name,age):
self.name = name
self.age = age
Animal.count += 1



dog = Animal('wangwang',1)
print(Animal.count)
cat = Animal('mimi',3)
print(Animal.count)
# Enter a code
class Animal(object):
count = 0
def __init__(self,name,age):
self.name = name
self.age = age
Animal.count += 1



dog = Animal('wangwang',1)
cat = Animal('mimi',3)

print(dog.count)
print(cat.count)
# Enter a code
class Animal(object):
def __init__(self,name,age):
self.name = name
self.age = age

dog = Animal('dog',1)
cat = Animal('cat',2)

print(dog.name,dog.age)
print(cat.name,cat.age)
# Enter a code
class Animal():
pass

dog = Animal()
cat = Animal()

print(dog)
print(cat)
print(dog == cat)
.append(f)——向list中追加的是函數f的對象引用
.append(f())——追加的是函數f的返回結果
運行參考答案還是一直報錯
class Animal(object):
__age = 2
def __init__(self, name, age):
self.name = name

cat = Animal('Kitty', '3')

print(cat.name)
print(cat._Animal__age)
叮叮叮,打卡
課程須知
本課程是Python入門的后續課程 1、掌握Python編程的基礎知識 2、掌握Python函數的編寫 3、對面向對象編程有所了解更佳
老師告訴你能學到什么?
1、什么是函數式編程 2、Python的函數式編程特點 3、Python的模塊 4、Python面向對象編程 5、Python強大的定制類

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!

本次提問將花費2個積分

你的積分不足,無法發表

為什么扣積分?

本次提問將花費2個積分

繼續發表請點擊 "確定"

為什么扣積分?

舉報

0/150
提交
取消