kartlad
kartlad

Reputation: 243

How to take input in beginning of the program in python?

NOTE: I have posted a very similar question by myself but please note before duplicating this question that the language is different this is a python and that is a shell script. I am making a program in python which needs the user input in the beginning of the program if you don't get my question I will give you an example:

I am making a program which needs the user input in the beginning of the program if you don't get my question I will give you an example:

./script.py "some-input"

So, I want the input in the beginning of the program. I think the input will be stored in a variable. If yes, Then please tell me in which variable it is stored. I am a Python rookie please never hesitate to correct the question. Thank you!

Upvotes: 0

Views: 800

Answers (1)

Ohad Eytan
Ohad Eytan

Reputation: 8464

You can access that variable via:

import sys
sys.argv[1]

more details and examples can be found here

Upvotes: 2

Related Questions