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 xxx


from sys import argv

python ./ 1 2 output:./ 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 <image_filename>")

Some parameters must be executed, so you can judge the