argparse
Stdlib — CLIPython 3.2+Intermediate
Parse command-line arguments with type checking and help messages
Quick Info
- Documentation
- Official Docs
- Python Version
- 3.2+
- Dependencies
- None — Python Standard Library
- Install
Included with Python
Learn by Difficulty
Quick Example
python
import argparse # argparse is for CLI argument parsing parser = argparse.ArgumentParser(description="Example CLI") parser.add_argument("--name", default="World") parser.add_argument("--count", type=int, default=1) # Simulate parsing (can't use sys.argv in Pyodide) args = parser.parse_args(["--name", "Python", "--count", "3"]) print(f"Hello, {args.name}! (x{args.count})")
The argparse module is part of Python's standard library. Parse command-line arguments with type checking and help messages.
Try in PlaygroundTags
stdlibclicommand-lineargument-parsing