class Animal(object):
def __init__(self,name,age):
self.name=name
self.age=age
pass
dog: Animal = Animal('dog',3)
cat = Animal('cat',5)
def __init__(self,name,age):
self.name=name
self.age=age
pass
dog: Animal = Animal('dog',3)
cat = Animal('cat',5)
2024-09-19
写的一言难尽。。。。推荐大家耐心看这个算了廖雪峰python学习:https://liaoxuefeng.com/books/python/introduction/index.html
2024-09-13
L = ['alice', 'BOB', 'CanDY']
def trans(theStr):
return str(theStr).title()
for item in map(trans,L):
print(item)
def trans(theStr):
return str(theStr).title()
for item in map(trans,L):
print(item)
2024-07-09
最新回答 / 慕函数7083591
# Enter a code# coding=utf-8class Animal(object): passdog = Animal()dog.name = '汪汪'dog.age = 7# 三种方式都可以,最后一种3.6新功能,在网页上还不支持,可以本地执行print("%s : %s" % (dog.name, dog.age))print("{} : {}".format(dog.name, dog.age))print(f"{dog.name}: {dog.age}")cat = Anima...
2024-06-11
因为是在类上调用,而非实例上调用,因此类方法无法获得任何实例变量,只能获得类的引用,这句话是啥意思,上面都挺明白,这个话突然理解不了了
2024-05-24