Using argparse to parse arguments of form “arg= val”

后端 未结 4 1431
时光说笑
时光说笑 2020-12-14 18:20

I want to use argparse to parse command lines of form \"arg=val\" For example, the usage would be:

script.py conf_dir=/tmp/good_conf

To ach

4条回答
  •  时光取名叫无心
    2020-12-14 19:08

    The usual way to put name value pairs on the command line is with options. I.e. you would use

    python script.py --confdir=/tmp/good_conf
    

    argparse can certainly handle that case. See the docs at:

    http://docs.python.org/library/argparse.html#option-value-syntax

提交回复
热议问题