What does import json do?
Options
- It downloads the json library from the internet every time
- It makes the
jsonmodule's code available in your file (Correct option) - It creates a new empty file called json in the folder
- It deletes any variable that is named json
Answer
Makes the code of the json module available in your file (here, the standard library's JSON tools)
Why
Python code is organized in modules (files) and packages (folders of modules).
import json loads the standard-library module that reads and writes JSON, so you can write json.loads(text).
Packages that are not in the standard library, like requests or fastapi, must be installed first with pip.
Remember
import = bring someone else's code into your file.