python from sys import argv
Published: 2019-04-20

If you want to pass parameters to python scripts, you need the support of command line parameters, so you can save every time you change scripts.

usage is: python xx.py xxx

 

from sys import argv
print(argv[0])
print(argv[1])

python ./argvTest.py 1 2 output:./argvetest.py 1 argv [ 1 ] represents the first parameter, 0 is the script file name path

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print ("Usage: python recognizer.py <image_filename>")

Some parameters must be executed, so you can judge the http://www.waitingfy.com/archives/3901