2.type、object和class的关系

type

1.返回数据的类型

>>> a=1
>>> type(1)
<class 'int'>
>>> type(int)
<class 'type'>
#type生成int类型,int生成 1
type ==>int==>1
type生成class,class生成obj(对象)

2.动态创建类对象

Student = type('Studnet',(object,),{'hello':hello,'name':'zzh'})

                         类名          继承         方法           属性

object

是最顶层的基类

猜你喜欢

转载自blog.csdn.net/weixin_40744265/article/details/89027469
今日推荐