Using command line arguments when running a python script (python)
When running a Python script from the command line, you can pass arguments separated by spaces.
python script.py arg1 arg2
To access the arguments in the script, use the sys
module.
sys.argv
is a list of command line arguments where the first element (sys.argv[0]
) is the name of the script.