Python – Module sys
The python sys module provides functions and variables which are used to manipulate different parts of the Python Runtime Environment. It lets us access system-specific parameters and functions
https://www.javatpoint.com/python-sys-module
import sys
Here are the most useful functions for me:
sys.exit()
Exit from the python code. All code after this will not be executed
import sys sys.exit()
sys.argv
Return a list of values with all the arguments you entered through command line.
Be aware the first element is the name of your Python’s script. You will need to slice it with sys.argv[1:] to take all arguments except the first one (0 is the first list’s member).
#! python2.7 import sys arguments=sys.argv[1:] print(sys.argv) for a in arguments: count=1 dico = {} dico['arg' + str(count)] = a print('My name is %s') %(a) count+=1
If you enter in command line the the following code
py 'name_of_this_script.py' totoro nemo dory pascal
You will have the following result
