I am using the following code to read JSON data saved in a text file. However, this code returns the following error:
raise TypeError(f'the JSON object must be str, bytes or bytearray, ' TypeError: the JSON object must be str, bytes or bytearray, not TextIOWrapper
The code is here:
with open('datafile.txt', 'r') as f:
data = json.loads(f)
What is wrong with this code?