網站首頁 學習教育 IT科技 金融知識 旅遊規劃 生活小知識 家鄉美食 養生小知識 健身運動 美容百科 遊戲知識 綜合知識
當前位置:趣知科普吧 > IT科技 > 

python的object

欄目: IT科技 / 發佈於: / 人氣:6.93K

python object是怎樣的呢?下面就讓我們一起來了解一下吧:

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

Tags:Python object