Introduction to argparse
Agrparse makes it easy to write user-friendly command line interfaces. This module automatically generates help and usage messages when users passed the invalid arguments to the program.
To understand the whole concept of the argparse module we will go through an example.
Let’s define a function which calculates the total marks a student got in all subjects.
The whole code is like this -:
If you run this program normally in idle it will show the output as -:
RESTART: C:PythonPython36file_name.py = 3.0.
It is giving three as output because of default parameters.
In command line, you can run these commands and get the output