On 03/17/2015 06:30 PM, Doug Basberg wrote:
I appreciate the advise to use json to pass a dict thru a file.  Below is
the code
To 'dump' the dict to a file and the code to 'load' the dict and the error
message
I get testing this.

What am I doing wrong?  Thanks.

First two things I see are that you used the "ab" mode to write the file, and "r" to read it.

if you're appending, then the second time you run it, there'll be extra junk at the end.

If you're reading in text mode, then linefeeds might get abused. When dealing with binary data, be sure and use "rb".


.....

Traceback (most recent call last):
   File "C:/Python27/myTestRcv00.py", line 17, in <module>
     dataDict = json.load(f)
   File "C:\Python27\lib\json\__init__.py", line 290, in load
     **kw)
   File "C:\Python27\lib\json\__init__.py", line 338, in loads
     return _default_decoder.decode(s)
   File "C:\Python27\lib\json\decoder.py", line 368, in decode
     raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 1 column 85 - line 1 column 421 (char 84 - 420)


--
DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to