Jan-08-2017, 07:19 AM
Thank you Larz for the reply my friend. I think I'm catching on to how to use the syntax for dict() except when it comes to reading from file. I get a weird error in the following code:
Not sure if it matter at all but I typed this into the json file just for testing purposes.
[Image: Screenshot%20from%202017-01-08%2001-14-2...fmzshy.png]
import json usrdatalist = dict() # Open file to read with open("usrdata.json", 'r') as f: j = f.read() usrdatalist = json.load(j)
Error:/usr/bin/python3.5 /root/PythonProjects/video_game/registry.py
Traceback (most recent call last):
File "/root/PythonProjects/video_game/registry.py", line 10, in <module>
usrdatalist = json.loads(j)
File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.5/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Process finished with exit code 1
I don't understand because I don't actually have anymore than 7 lines in the code at this point. LOL 
Not sure if it matter at all but I typed this into the json file just for testing purposes.
[Image: Screenshot%20from%202017-01-08%2001-14-2...fmzshy.png]