Pythonの標準ライブラリである”argparse”はコマンドラインオプションや引数、サブコマンドのパーサを生成しそれらをパースする機能を提供します。argparseを使用することで、Pythonスクリプトはコマンドラインからの引数を簡単に取り扱うことができます。
Pythonでスクリプトを作って、ターミナルから python script.py data.txt のように引数を渡して実行することはよくあります。 この時、簡易的に sys.argv を使うこともできますが、引数が増えてきたり、オプション指定(-h や --verbose)に対応しようとすると、自力で ...
argparse requires to create subparsers first and then add the subcommands to the subparsers. argx allows to add subcommands directly to the main parser. If you have a lot of arguments, the help ...