Puthon to take command line arguments on running a script. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Puthon to take command line arguments on running a script.

5th Aug 2017, 8:27 AM
Birendra Singh
Birendra Singh - avatar
2 Answers
+ 6
Use module 'sys' and its 'argv' list: import sys print(len(sys.argv)) # number of command line 'arguments' (including the running script file name at index zero) However, you can use the 'getopt' module to more easily handle them: https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_command_line_arguments.htm
5th Aug 2017, 9:50 AM
visph
visph - avatar
+ 1
thanks dear
5th Aug 2017, 12:39 PM
Birendra Singh
Birendra Singh - avatar