When the code is changed from python2.7 to python3.5, the dict data type reports an error
Cause: dict.has_key() ; This method is removed in Python 3
Solution: use
if key in dict : Change to if dict.has_key(key):
Similar Posts:
- AttributeError: ‘dict’ object has no attribute ‘has_key’
- PaddlePaddle Error: ‘map’ object is not subscriptable
- [Solved] Python error: attributeerror: type object ‘STR’ has no attribute ‘_name_’ (machine learning practice treeplotter code)
- [Solved] Python Error: TypeError: ‘dict_keys’ object does not support indexing
- TypeError: ‘dict_keys’ object does not support indexing
- Python3: list dict set [UNK]unhashable type
- Problem solving: error in reading CSV file by Panda: typeerror: invalid type comparison
- [Solved] TypeError: string indices must be integers, not str
- Transport Security has blocked a cleartext HTTP [How to Solve]
- Flask Accessing an interface that returns a dictionary error: The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.