Reading JSON from a file [duplicate]
Problem:
An attempt to read data from a JSON file using json.loads(json_data) generates errors, including "expected string or buffer" and "Extra data."
Answer:
The appropriate method for reading JSON data from a file is json.load(), not json.loads(). The latter is used for string arguments only.
import json with open('strings.json') as f: d = json.load(f)
The above is the detailed content of How to Properly Read JSON Data from a File in Python?. For more information, please follow other related articles on the PHP Chinese website!