with open('./text.txt','a+') as f1:
f1.seek(0)
lines=f1.readlines()
f1.seek(2)
for v in lines:
f1.write(v)
f1.seek(0)
lines=f1.readlines()
f1.seek(2)
for v in lines:
f1.write(v)
2021-04-15
import math
x=math.sin(0)
from math import cos
y=cos(0)
print(x,y)
x=math.sin(0)
from math import cos
y=cos(0)
print(x,y)
2021-04-14
class Student():
def __init__(self,name,gender,score):
self.name,self.gender=name,gender
self.score=score
def __str__(self):
return 'Student:{},{},{}'.format(self.name,self.gender,self.score)
s=Student('xiaowang','girl','98')
print(str(s))
def __init__(self,name,gender,score):
self.name,self.gender=name,gender
self.score=score
def __str__(self):
return 'Student:{},{},{}'.format(self.name,self.gender,self.score)
s=Student('xiaowang','girl','98')
print(str(s))
2021-04-13
print(isinstance(t,Person))
print(isinstance(t,Student))
print(isinstance(t,Teacher))
print(isinstance(t,object))
print(isinstance(t,Student))
print(isinstance(t,Teacher))
print(isinstance(t,object))
2021-04-12
class Animal():
_count=0
@classmethod
def get_count(cls):
Animal._count+=1
return cls._count
print(Animal.get_count())
print(Animal.get_count())
_count=0
@classmethod
def get_count(cls):
Animal._count+=1
return cls._count
print(Animal.get_count())
print(Animal.get_count())
2021-04-11
class Animal(object):
def __init__(self, name, age):
self.name = name
self.age = age
dog = Animal("小黄", 2)
cat = Animal("小花", 3)
print(dog.name,dog.age)
print(cat.name,cat.age)
def __init__(self, name, age):
self.name = name
self.age = age
dog = Animal("小黄", 2)
cat = Animal("小花", 3)
print(dog.name,dog.age)
print(cat.name,cat.age)
2021-04-09
class Animal():
count=0
def __init__(self,name,age):
self.name=name
self.age=age
Animal.count+=1
dog=Animal('wangwang','2years old')
cat=Animal('mimi','1yeaes old')
print(Animal.count)
count=0
def __init__(self,name,age):
self.name=name
self.age=age
Animal.count+=1
dog=Animal('wangwang','2years old')
cat=Animal('mimi','1yeaes old')
print(Animal.count)
2021-04-09
class Animal():
def __init__(self,name,age):
self.name=name
self.age=age
dog=Animal('wangcai','3岁')
cat=Animal('mimi','2岁')
print(dog.name,dog.age)
print(cat.name,cat.age)
def __init__(self,name,age):
self.name=name
self.age=age
dog=Animal('wangcai','3岁')
cat=Animal('mimi','2岁')
print(dog.name,dog.age)
print(cat.name,cat.age)
2021-04-08
class Dog():
pass
class Cat():
pass
dog=Dog()
cat=Cat()
print(dog)
print(cat)
print(dog==cat)
pass
class Cat():
pass
dog=Dog()
cat=Cat()
print(dog)
print(cat)
print(dog==cat)
2021-04-08