新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python如何看變量屬性
python中查看變量屬性的

我們是2013年至今的成都網(wǎng)站建設(shè)公司,提供網(wǎng)站建設(shè),電商網(wǎng)站設(shè)計(jì)開發(fā),外貿(mào)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)頁設(shè)計(jì),微信小程序定制開發(fā)、等服務(wù)。為客戶創(chuàng)造有價(jià)值的品牌營銷體驗(yàn),讓互聯(lián)網(wǎng)提升企業(yè)的競爭力!
1、使用dir()函數(shù)查看
dir() 函數(shù)不帶參數(shù)時(shí),返回當(dāng)前范圍內(nèi)的變量、方法和定義的類型列表;帶參數(shù)時(shí),返回參數(shù)的屬性、方法列表。
$ python Python 2.7.8 (default, Sep 24 2015, 18:26:19) [GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> 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 (most recent call last): File "", line 1, in TypeError: vars() argument must have __dict__ attribute >>> mser.__dict__ Traceback (most recent call last): File " ", line 1, in AttributeError: 'cv2.MSER' object has no attribute '__dict__'
當(dāng)前題目:創(chuàng)新互聯(lián)Python教程:python如何看變量屬性
網(wǎng)站路徑:http://fisionsoft.com.cn/article/cddjsee.html


咨詢
建站咨詢
