Repaso
EspaƱol
PythonFoundationsPY-67

What does import json do?

Options

  1. It downloads the json library from the internet every time
  2. It makes the json module's code available in your file (Correct option)
  3. It creates a new empty file called json in the folder
  4. 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.

Key terms

Practice this question in Repaso