定义Pyhton中的类
```python
class Student: #Student为类的名称
native_place='hubei' #直接写在类里的变更,称为类属性
def __init__(self,name,age): #默认方法
self.name=name #self.name称为实例属性,在这里进行了一个赋值操作,将局部变量值name赋给实例属性
self.age=age
#类中定义的实例方法
def eat(self): #默认传self
print('学生在吃饭')
#静态方法
@staticmethod
def method():
print('我使用了staticmethod进行修饰,所以我是静态方法')
#类方法
@classmethod
def cm(cls): #默认传cls
print('我是类方法,因为我使用了classmethod修饰')
#在类之外定义的称为函数,在类里面定义的称为方法
def drink(): #我在类之外定义,所以称之为函数
print('学生在喝水')
print('-'*20)
#创建Student类的对象
stu1=Student('zhangsan',20)
print(stu1.name)
print(stu1.age)
#使用类中的方法,都是调用Student中的eat方法; 对象名.方法名()
stu1.eat()
#使用类中的方法2,都是调用Student中的eat方法; 类名.方法名(类的对象),要求传入类的对象;实际上就是类方法定义的self
Student.eat(stu1)
print('-'*20)
#类属性的使用方式
print(Student.native_place)
stu1=Student('张三',20)
stu2=Student('李四',30)
print(stu1.native_place)
print(stu2.native_place)
Student.native_place='天津'
print(stu1.native_place)
print(stu2.native_place)
print(stu1.name,stu1.age)
print('-'*20)
#类方法的使用方式
Student.cm()
#静态方法的使用方法
Student.method()