Argparse:"-p"或"-p=value"但不是"-pvalue"
有没有办法添加一个只能用作-por的参数-p=value,但不能-p value
我想向--parallel/-p脚本添加一个可选参数。这是我希望用户传递它的方式:
./script arg1 arg2 -p # this defaults to 10
./script arg1 arg2 -p=13 # This is fine and will set the value to 13
./script arg1 arg2 -p 13 # This is NOT fine and I want to ban this. Next line will tell why.
./script -p arg1 arg2 # I want -p to be usable regardless of its position.
# But here arg1 will be considered as an argument of -p option, which is unwanted.