When using JSON in Python to read a JSON file, an error is reported because the corresponding method is used incorrectly: typeerror: the JSON object must be STR, bytes or byte array, not ‘textiowrapper’.
Solution: first of all, we need to understand that there are four methods for JSON: dumps and loads, dump and load. Among them, dumps and loads are converted in memory (the conversion between Python objects and JSON strings), while dump and load are the processing corresponding to files.
The reason for this error is that I used the loads method to convert the JSON file into a python object, and the correct way is to use the load method.
Read More:
- typeerror:the josn object must be str,bytes or byteearray,not ‘dict‘
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- Typeerror: write() argument must be STR, not bytes and the method of writing binary file in Python 3
- Object of type timestamp is not JSON serializable
- “Typeerror: List indexes must be integers or slices, not STR” about error reporting solutions
- Property or field ‘Title‘ cannot be found on object of type
- 【ipfs-api】npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
- AttributeError: ‘_io.TextIOWrapper‘ object has no attribute ‘softspace‘
- nvalid default value for prop “params“: Props with type Object/Array must use a factory function to
- [Solved] ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
- [jQuery] jQuery operates on JSON strings or JSON objects
- Python json.dumps () json.dump The difference between ()
- JSON parse e rror: Invalid UTF-8 middle byte 0x3f;
- type of the byte recordError: webpackMerge is not a function
- TypeError: object of type ‘builtin_function_or_method’ has no len()
- Springmvc Content type ‘application/json‘ not supported
- array type has an incomplete element type
- The JSON object is converted into a formdata object, and the formdata object is converted into a JSON object
- Type error: sequence item 0: expected STR instance, int found
- Error tips:array type has incomplete element type