I am trying to read a JSON file that I saved in a text file using the ploadon.loads () function. Then I will parse JSON to get a specific value.
I keep getting this error message. When I do this, there are no results.
UnicodeDecodeError: ascii codec cannot decode byte 0xc2 at position> 85298: serial number not in range (128)
Here is the complete error message:
Traceback (last last call): File "... / FirstDegreeKanyeScript.py",> line 10, in data = json.load (data_file) File> "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3 .5 / json / in> it .py ", line 265, at load loads (fp.read (), File>" /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings> / ascii.py ", line 26, in the decoder return codecs.ascii_decode (input,> self.errors) [0] UnicodeDecodeError: the ascii codec cannot decode byte 0xc2> at position 85298: the serial number is not in the range (128)
Here is my code:
import json
from pprint import pprint
with
open("/Users/.../KanyeAllSongs.txt") as data_file:
data=json.load(data_file)
pprint(data)
I tried adding data.decode('utf-8')under json.load, but I still get the same error.
Any ideas what could be the problem?