Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (50.2k points)

I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments.

What are some of the ways Python programmers can do this?

1 Answer

0 votes
by (106k points)
edited by

To read different arguments in Python we will use sys.argv() method:-

import sys

print("\n".join(sys.argv))

sys.argv is a list that contains all the arguments passed to the script on the command line. 

So below mentioned code validates that sys.argv()is a list:-

import sys 

print(sys.argv[1:])

image

To know more about this you can have a look at the following video tutorial:-


 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...