预留广告位
预留广告位
预留广告位
当前位置:首页  »  科技  »  科技百科  »  文章  »  python object

python object

来源:网络 转载:好巧合 时间:2022-01-22 21:31
导读python object,object是属于python下的一个函数,具体为object类,object类是属于所有类的父类,简单来说就是其它的任何一个类,都在直接或者间接地继承了object类的属性与方法。

python object是怎样的呢?下面就让我们一起来了解一下吧:

object是属于python下的一个函数,具体为object类,object类是属于所有类的父类,简单来说就是其它的任何一个类,都在直接或者间接地继承了object类的属性与方法。

用法即object()

参数:

None

参考范例:

演示object()的工作,输入命令:

# Python 3 code to demonstrate  

# working of object() 

  

# declaring the object of class object 

obj = object() 

  

# printing its type  

print ("The type of object class object is:") 

print (type(obj)) 

  

# printing its attributes 

print ("The attributes of its class are:") 

print (dir(obj))

输出结果:

The type of object class object is:

The attributes of its class are:

[‘__class__’, ‘__delattr__’, ‘__dir__’, ‘__doc__’, ‘__eq__’, ‘__format__’, ‘__ge__’, ‘__getattribute__’, ‘__gt__’, ‘__hash__’, ‘__init__’, ‘__le__’, ‘__lt__’, ‘__ne__’, ‘__new__’, ‘__reduce__’, ‘__reduce_ex__’, ‘__repr__’, ‘__setattr__’, ‘__sizeof__’, ‘__str__’, ‘__subclasshook__’]

以上就是小编的分享了,希望能够帮助到大家。

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。

预留广告位
标签:python  object  
Top