python object是怎樣的呢?下面就讓我們一起來了解一下吧:
object是屬於python下的一個函數,具體爲object類,object類是屬於所有類的父類,簡單來說就是其它的任何一個類,都在直接或者間接地繼承了object類的屬性與方法。
用法即object()
參數:
None
參考範例:
# 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__’]