sys.argv[1] what is the meaning of it?

0 votes
I am new to python and was wondering whether sys.argv[1] is?

Is it simply a statement for taking an input.
Dec 17, 2018 in Python by Anjali
• 2,950 points
3,572 views

1 answer to this question.

0 votes

sys.argv[1] contains the first command line argument passed to your script.

For example, if your script is named hello.py and you issue:

$ python3.1 hello.py foo

or:

$ chmod +x hello.py  # make script executable
$ ./hello.py foo

Your script will print:

Hello there foo
answered Dec 17, 2018 by abc

Related Questions In Python

0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 57,700 points
230 views
0 votes
1 answer

.What is the meaning of "while True :" while doing in a loop.

The body of the loop will continue ...READ MORE

answered Oct 7 in Python by Gitika
• 42,060 points
19 views
+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
2,453 views
0 votes
2 answers

What is the use of Python language?

python is general purpose programming language.it very ...READ MORE

answered Mar 15, 2019 in Python by rajesh kumar
102 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,472 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,800 points
1,103 views
0 votes
1 answer

What is the difference between staticmethod and classmethod?

A staticmethod is a method that knows nothing about ...READ MORE

answered Dec 17, 2018 in Python by abc
152 views
0 votes
1 answer

What does calling a function means in Python?

Calling a function means that you are ...READ MORE

answered Dec 17, 2018 in Python by Shuvodip
163 views