In python the sys module is used to use the command line arguments. There are three important steps to be followed while accessing the command line arguments
Command Line Arguments AU
: Dec.-19, Marks 2
In
python the sys module is used to use the command line arguments. There are
three important steps to be followed while accessing the command line arguments
1.
Import the sys module
2.
We can use sys.argv for getting the list of command line arguments.
3.
The len(sys.argv) gives total number of command line arguments.
The
python program illustrating the access to command line arguments is as given
below.
Step
1:
Write a python script as follows. Here the name of the script file is CmdLine.py
Step
2:
The command prompt window is opened and type the python command at the prompt
and we get the output of the above program
Review Question
1. How to use command line arguments in Python. AU : Dec.-19, Marks 2
Problem Solving and Python Programming: UNIT V: Files, Modules, Packages : Tag: Engineering Python : Files | Python Programming - Command Line Arguments
Problem Solving and Python Programming
GE3151 1st Semester | 2021 Regulation | 1st Semester Common to all Dept 2021 Regulation