1、使用dir()函數(shù)查看
dir()函數(shù)不帶參數(shù)時(shí),返回當(dāng)前范圍內(nèi)的變量、方法和定義的類型列表;帶參數(shù)時(shí),返回參數(shù)的屬性、方法列表。
$python
Python2.7.8(default,Sep242015,18:26:19)
[GCC4.9.220150212(RedHat4.9.2-6)]onlinux2
Type"help","copyright","credits"or"license"formoreinformation.
>>>importcv2
>>>mser=cv2.MSER()
>>>dir(mser)
['__class__','__delattr__','__doc__','__format__','__getattribute__','__hash__','__init__','__new__','__reduce__','__reduce_ex__','__repr__','__setattr__','__sizeof__','__str__','__subclasshook__','detect','empty','getAlgorithm','getBool','getDouble','getInt','getMat','getMatVector','getParams','getString','paramHelp','paramType','setAlgorithm','setBool','setDouble','setInt','setMat','setMatVector','setString']
2、使用vars()函數(shù)查看
vars()函數(shù)返回對(duì)象object的屬性和屬性值的字典對(duì)象。
>>>vars(mser)
Traceback(mostrecentcalllast):
File"",line1,in
TypeError:vars()argumentmusthave__dict__attribute
>>>mser.__dict__
Traceback(mostrecentcalllast):
File"",line1,in
AttributeError:'cv2.MSER'objecthasnoattribute'__dict__'
以上內(nèi)容為大家介紹了python如何看變量屬性,希望對(duì)大家有所幫助,如果想要了解更多Python相關(guān)知識(shí),請(qǐng)關(guān)注IT培訓(xùn)機(jī)構(gòu):千鋒教育。