Hi, I am very newly learning Python and am trying to figure out where the files import from when writing the code. For example, I’m trying to “import json” in video 39, but I’m getting this error:
Traceback (most recent call last):
File “C:\Users\chels\PythonPrograms\json1.py”, line 13, in
info=json.loads(data)
File “C:\Users\chels\AppData\Local\Programs\Python\Python310\lib\json_
init
_.py”, line 346, in loads
return _default_decoder.decode(s)
File “C:\Users\chels\AppData\Local\Programs\Python\Python310\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Users\chels\AppData\Local\Programs\Python\Python310\lib\json\decoder.py”, line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ‘,’ delimiter: line 7 column 6 (char 111)
I’ve been able to find .txt files from the zip code3 file that I downloaded, but where do I find these xml documents?
Usually file are imported according to their location relative to the file doing the import.
So there should be something within the “data” variable containing that information.
It would be helpful if you included your code that causes the problem and maybe the video you are referring to because I have no idea what “video 39” is ^^°
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (
</>
) to add backticks around text.
Pre-formatted-text
1356×380 401 KB
See
this post
to find the backtick on your keyboard.
Note:
Backticks (`) are not single quotes (’).
Now things make more sense.
Look back at the traceback error, there are two keys to understand it:
First it lists all the files it’s currently working on - first file is the actual open file and the others are from libraries and whatnot.
Then at the end is the actual error it encountered:
json.decoder.JSONDecodeError: Expecting ‘,’ delimiter: line 7 column 6 (char 111)
Line 7 refers to the data and it’s expecting a “,” there but got something else. Which usually means you forgot one in the line above.