IT科技

當前位置 /首頁/IT科技 > /列表

object,python

object是屬於python下的一個函數,具體為object類,object類是屬於所有類的父類,簡單來説就是其它的任何一個類,都在直接或者間接地繼承了object類的屬性與方法。

用法即object()

參數:

None

python object

參考範例:

演示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))

python object 第2張

輸出結果:

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__’]

TAG標籤:Python object #