AttributeError: 'dict' object has no attribute 'has_key'
使用版本是python 3.6
報錯語句如下:
File "D:\python\BuildFireRiskModel\BuildFireRiskModel\src\MiningUnit\DataUnit.py", line 80, in generatePyplotData
if attrListCluserDictDict.has_key(cluserName):
AttributeError: 'dict' object has no attribute 'has_key'
透過查資料得知,has_key函式在python3中已經被移除了。
在python文件中有說明:
From the documentation: Removed dict.has_key() – use the in operator instead.
因此,可改寫成如下:
if cluserName in attrListCluserDictDict:
報錯語句如下:
File "D:\python\BuildFireRiskModel\BuildFireRiskModel\src\MiningUnit\DataUnit.py", line 80, in generatePyplotData
if attrListCluserDictDict.has_key(cluserName):
AttributeError: 'dict' object has no attribute 'has_key'
透過查資料得知,has_key函式在python3中已經被移除了。
在python文件中有說明:
From the documentation: Removed dict.has_key() – use the in operator instead.
因此,可改寫成如下:
if cluserName in attrListCluserDictDict:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25465866/viewspace-2146387/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ‘dict‘ object has no attribute ‘iteritems‘Object
- AttributeError: 'module' object has no attribute 'lock'ErrorObject
- AttributeError: 'Settings' object has no attribute 'HBase'ErrorObject
- 問題解決:AttributeError: ‘NoneType‘ object has no attribute ‘append‘ErrorNoneObjectAPP
- AttributeError: module ‘requests‘ has no attribute ‘_version_‘Error
- Rasa init報錯:AttributeError: type object 'Callable' has no attribute '_abc_registry'ErrorObject
- Traceback (most recent call last): File "AttributeError: 'NoneType' object has no attribute 'group'ASTErrorNoneObject
- Process object has no attribute '_popen'Object
- [轉]成功解決AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘?Error
- ‘FirewallD‘ object has no attribute ‘path‘ 、‘fw‘、is not registeredObject
- 【坑】Tkinter ‘NoneType‘ object has no attribute ‘destroy‘NoneObject
- AttributeError: module...ops‘ has no attribute ‘_TensorLike‘, ValueError: `updates` argument..eagerError
- AttributeError: module ‘tensorflow._api.v1.nn.rnn_cell‘ has no attribute ‘InputProjectionWrapper‘ErrorAPIRNNProjectAPP
- 【Error】AttributeError: module ‘scipy.misc‘ has no attribute ‘logsumexp‘ 的解決辦法Error
- 1_使用face_recognition模組:錯誤AttributeError:'PngStream' object has no attribute 'chunk fcWp'(20190223)ErrorObject
- AttributeError: module‘ tensorflow_core._api.v2. train‘ has no attribute‘ AdamOptimizer‘ErrorAPIAI
- python去掉excel空格和換行,報錯'int' object has no attribute 'strip'PythonExcelObject
- multiprocessing pool AttributeError: Can't get attribute 'func'Error
- 複雜網路中louvain演算法實現時報錯AttributeError: module ‘community‘ has no attribute ‘best_partition‘AI演算法ErrorUnity
- Uncaught TypeError: Object [object Object] has no method 'xxx'ErrorObject
- module ‘h5py‘ has no attribute ‘File‘H5
- module ‘tensorflow‘ has no attribute ‘get_default_graph‘
- Uncaught TypeError: Object # has no method 'load'ErrorObject
- 解決pycharm問題:module 'pip' has no attribute 'main'PyCharmAI
- object dict cannot be used in await expression報錯解釋ObjectAIExpress
- zt_powerdesigner_'find in diagram' 後彈出'the object has no symbol'ObjectSymbol
- Invalid configuration object webpack dev server has been initialisedObjectWebdevServer
- Oracle RAC crsd日誌-0Resource ora!dbtest2!vip has incomplete attribute setOracle
- python-unittest 框架利用 PageObject 設計模式在 BasePage 類中呼叫不到 send_keys 方法,執行報錯'NoneType' object has no attribute 'send_keys'Python框架Object設計模式None
- dict pop 原理
- Syntax Error: ValidationError: Invalid options object. Stylus Loader has been initialized using anErrorObjectZed
- Python dict(字典)Python
- python存取dictPython
- Python Dict用法Python
- jQuery [attribute]jQuery
- Attribute Checks
- 理解Spring MVC Model Attribute和Session AttributeSpringMVCSession
- jQuery has()jQuery