json.json

Home   »   json.json

In [6]: with open("/home/yoan/Téléchargements/advice.json") as f: 
   ...:     d = json.load(f) 
   ...:                                                                                                              
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
 in 
      1 with open("/home/yoan/Téléchargements/advice.json") as f:
----> 2     d = json.load(f)
      3 

/usr/lib/python3.8/json/__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    291     kwarg; otherwise ``JSONDecoder`` is used.
    292     """
--> 293     return loads(fp.read(),
    294         cls=cls, object_hook=object_hook,
    295         parse_float=parse_float, parse_int=parse_int,

/usr/lib/python3.8/codecs.py in decode(self, input, final)
    320         # decode input (taking the buffer into account)
    321         data = self.buffer + input
--> 322         (result, consumed) = self._buffer_decode(data, self.errors, final)
    323         # keep undecoded input until the next call
    324         self.buffer = data[consumed:]

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 2696: invalid continuation byte

In [7]: with open("/home/yoan/Téléchargements/advice.json", encoding="latin-1") as f: 
   ...:     d = json.load(f) 
   ...:      
   ...:                                                                                                              

In [8]: type(d)                                                                                                      
Out[8]: list

Leave a Reply

Your email address will not be published. Required fields are marked *