上面写的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
# 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
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 __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())
2022-12-17
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())
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())
2022-10-26
1、子类定义的时候,需要在括号内写明继承的类;
2、在__init__()方法,需要调用super(Student, self).__init__(name, gender),来初始化从父类继承过来的属性;
2、在__init__()方法,需要调用super(Student, self).__init__(name, gender),来初始化从父类继承过来的属性;
2022-09-24
# 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)
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)
2022-09-03
# 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)
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)
2022-09-03