sys.argv
in Python stands for "System Argument Values". It is a list in Python, which contains the command-line arguments passed to the script. With sys.argv
, one can run a script from the command-line and pass arguments to it.
Here's an example of how to use sys.argv
:
main.py200 chars8 lines
When you execute the above script by passing some command-line arguments, it will print those arguments along with the total number of arguments.
For example:
main.py130 chars4 lines
In this example, sys.argv[0]
is the name of the script itself, and the remaining elements are the arguments passed to it.
gistlibby LogSnag