最赞回答 / 慕前端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
上面写的seek的函数用法是错的,。他那参数代表的是偏移量,1就是在一个字符后,2就是两个字符后。。。。。。
而不是什么文件尾部!!!害我搞半天—_—#
而不是什么文件尾部!!!害我搞半天—_—#
2023-02-08
L = ['bob', 'about', 'Zoo', 'Credit']
sorted(L, key = lambda i:i[0].upper())
sorted(L, key = lambda i:i[0].upper())
2023-02-03
最新回答 / weixin_慕函数3435348
print('I hava a %s skill'%self.skill)都改成return 'I hava a %s skill'%self.skill。或者print(a.get_skill())改成a.get_skill()直接运行,因为你定义的def get_skill(self):自带打印了。
2023-01-28
# 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 animals:
def Setname(self,name):
self.name = name
print('{}'.format(self.name))
dog = animals()
dog.Setname('dog')
cat = animals()
cat.Setname('cat')
2023-01-11