Python·100 questions

How to read/write JSON?

Answer
import json.
json.loads(text) → dict/list.
json.dumps(obj, ensure_ascii=False) → string.
For files: json.load(fp), json.dump(obj, fp).
For datetime, convert (e.g., ISO string).
Was this answer helpful?

More questions in this topic

Related questions from other topics