Command-Line Modules
getopt
Parses short and long command-line options into option/value pairs and remaining operands. Colons and trailing equals signs declare required option values. Unlike argparse, it does not build a typed namespace or automatically produce application help.
Formal Syntax & Structure
python syntaxpython
import getoptReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import getoptoptions, operands = getopt.getopt(["-n", "3", "file"], "n:")print(options, operands)