时间:2022-07-29 09:24:11 | 栏目:Python代码 | 点击:次
在Python中, 可以使用type()类型来查看数据的类型:
>>> type(3)
<class 'int'>
>>> type("123")
<class 'str'>
>>> type(True)
<class 'bool'>
>>> x = 1 + 2j
>>> type(x)
<class 'complex'>

仔细思考,会不会Class是由type来定义的呢?
是的,其实Class是由 type来声明。

可以看到,type需要三个参数,你可以理解为:
问题来了,那如果定义私有函数呢?

可以看到,先定义一个函数,然后再用type定义类。
其中:
get_author : 私有函数名问题又来了,如果去继承呢?

OK,基本情况就是这样。