python练习

class Student():
    # sum1=0
    # name='qiyue'
    # age=0
    #
    # def __init__(self,name,age):
    #     #构造函数
    #     #初始化对象的属性
    #     self.name=name
    #     self.age=age
    #     self.__class__.sum1+=1
    #     self.__score=0
    #     print("the sum of student:"+str(self.__class__.sum1))
    #
    #     #print(self.__class__.sum1)


    def do_homework(self):
        print('homework')



    # @classmethod
    # def plus_sum(cls):
    #     cls.sum1+=1
    #     print(cls.sum1)
    #     print()
    #
    # @staticmethod
    # def add(x,y):
    #     print(Student.sum1)
    #
    #    # print("static method")
    #
    # def marking(self,score):
    #     if score<0:
    #         return "不能是-分"
    #     self.__score=score
    #     print(self.name+"score"+str(self.__score))



student2=Student()
print(student2.sum)
#print(student2.name)
#print(student2.age)
#student1=Student('123',18)
# result=student1.marking(59)
# student1.__score==-1
# print(student1.__dict__)
# student1.add(1,2)
# Student.add(1,2)

# student2=Student('4567',19)
# Student.plus_sum()
# student3=Student('3214',18)
# Student.plus_sum()
#print(student1.__dict__)
# print(student2.name)
# print(Student.name)
#print(Student.sum1)





猜你喜欢

转载自blog.csdn.net/Purpose1123/article/details/80385148