pycharm parameters run

pycharm parameters run


question

In github, something similar to the following will appear:

python3 inference_time_whole_model.py \
    --dataset nyuv2 \
    --no_time_pytorch \
    --no_time_onnxruntime \
    --trt_floatx 16

material

ArgumentParser.add_argument(name or flags...[, action][, nargs][, const][, default][, type][, choices][, required][, help][, metavar][, dest])

Defines how individual command line arguments should be parsed. Each parameter has its own further description below, but the short version is:
• name or flags A name or a list of option strings, such as foo or -f, --foo.
• action The action base type used when the argument appears on the command line.
• nargs The number of command line arguments that should be consumed.
• const Constant required by some actions and nargs selection.
• default The value produced when the parameter does not appear on the command line and does not exist in the namespace object.
• type The type that the command line argument should be converted to.
• choices A container for available parameters.
• required Whether this command line option can be omitted (only options are available).
• help A brief description of what this option does.
•Examples of metavar parameter values ​​used in usage messages.
• dest is the attribute name added to the object returned by [parse_args()].


Example 1

python 111.py 
	--n1=1 
	--n2=2 
	--n3=3  
	--n4=4

python file 111.py

import argparse

# 将命令行中输入的数字组合成一个四位数
parser = argparse.ArgumentParser(description='命令行中输入若干个数字')
parser.add_argument('--n1', type=int, help='输入第一个数字')
parser.add_argument('--n2', type=int, help='输入第二个数字')
parser.add_argument('--n3', type=int, help='输入一个数字')
parser.add_argument('--n4', type=int, help='输入一个数字')
args = parser.parse_args()
ans = 0
ans = 1000 * args.n1 + 100 * args.n2 + 10 * args.n3 + args.n4
print(ans)

method one

Just enter the code directly in the terminal window after entering the environment.

Method Two

Click Run

Edit Configuration

Configuration Parameters

Run Results


More specific reference blog: Detailed explanation of python add_argument() method

Guess you like

Origin blog.csdn.net/wagnbo/article/details/127758910