0Pricing
Python Academy · Lesson

The Click Library

Create CLIs with decorators.

What Is Click?

Click is a popular third-party library for building command-line interfaces using decorators. It handles parsing, help text, prompts, and colors with very little code. Install it with pip install click.

import click

@click.command()
def hello():
    click.echo('Hello from Click')

# hello() would run when called as a script

click.echo

Use click.echo() instead of print. It handles encoding issues and works smoothly with Click's color and redirection features.

import click

@click.command()
def greet():
    click.echo('Welcome!')

All lessons in this course

  1. argparse Basics
  2. Subcommands and Options
  3. The Click Library
  4. Rich Terminal Output
← Back to Python Academy