January 2019
Beginner
318 pages
8h 23m
English
The sys module is used to access command-line parameters. The len(sys.argv) function contains the number of arguments. To print all of the arguments, simply execute str(sys.argv). Let's have a look at an example:
01.pyimport sysprint('Number of arguments:', len(sys.argv))print('Argument list:', str(sys.argv))Output:Python3 01.py imgNumber of arguments 2Arguments list: ['01.py', 'img']
Read now
Unlock full access