with open('file.json', "r") as input_file:
data = json.load(input_file)
print(data)
This is my piece of code of reading a json file. It works fine with I run it in a.py, but it gave me error when i put it on Jupyter Notebook as follows:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The json file looks like this: Can anyone help me with it. Thanks
You need read() to import the json into your file according to this:
with open('sample_tweets.json', "r") as input_file:
data = json.load(input_file.read())
I could not verify it with your json file, but that is the way it works for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.