最新回答 / 時頌望見
7/103/101/105/2[Done] exited with code=0 in 0.069 seconds没问题啊,可以正常运行,你复制的时候漏了啥吧
2023-11-23
最新回答 / qq_青萍之末_2
# 关于你这个情况,我尝试了两种理解方法,我自己称为显示调用和继承式调用,具体代码如下:class Person(object): def __init__(self, name, gender): self.name = name self.gender = genderclass Student(Person): def __init__(self, name, gender, score): super(Student, self).__init...
2023-10-08
最赞回答 / 慕前端5377531
前两行是对象在内存中的地址,每个Python对象都有一个唯一的内存地址,用于标识该对象在内存中的位置。通常情况下,我们不需要直接操作对象的内存地址,而是通过对象的属性和方法来访问和修改其值。后面就布尔类型值,表示不相等
2023-08-30
def f(list1=[]):
str=''.join(list1)
l=str.title()
list3=[]
list3.append(l)
return list3
for item in map(f, ['alice','BOB','CanDY']):
print(item)
str=''.join(list1)
l=str.title()
list3=[]
list3.append(l)
return list3
for item in map(f, ['alice','BOB','CanDY']):
print(item)
2023-07-25
# Enter a code
class Person():
pass
dog= Person()
cat = Person()
dog.name = 'xiaodog'
dog.sex = 'man'
dog.age = 2
cat.name = 'xiaocat'
cat.sex = 'man'
cat.age = 3
print(dog.name)
print(dog.sex)
print(dog.age)
print(cat.name)
print(cat.sex)
class Person():
pass
dog= Person()
cat = Person()
dog.name = 'xiaodog'
dog.sex = 'man'
dog.age = 2
cat.name = 'xiaocat'
cat.sex = 'man'
cat.age = 3
print(dog.name)
print(dog.sex)
print(dog.age)
print(cat.name)
print(cat.sex)
2023-07-15
最赞回答 / Jump丶
dog.instance_count = dog.instance_count+1 实际上不是在操作类属性 而是在dog实例上新增了一个 instance_count属性,然后你再次访问的时候因为优先级 你访问不到类上的属性了 所以操作类属性最好使用Animal.instance_count
2023-06-09
class Animal:
def __init__(self,name,age):
self.name = name
self.age = age
def get_information(self):
print(self.name,self.age)
dog = Animal('小小',12)
cat = Animal('大大',2)
dog.get_information()
cat.get_information()
def __init__(self,name,age):
self.name = name
self.age = age
def get_information(self):
print(self.name,self.age)
dog = Animal('小小',12)
cat = Animal('大大',2)
dog.get_information()
cat.get_information()
2023-06-08
最新回答 / weixin_慕九州1173902
z=y() 调用的 最里面的h()函数,该函数没有返回值,所以z是Nonedef h(): print('call h()...')
2023-05-29