Linked Questions
51 questions linked to/from User input and command line arguments
1808 votes
25 answers
2.2m views
How do I read from stdin?
How do I read from standard input (stdin)?
843 votes
22 answers
830k views
How can I read and process (parse) command line arguments?
In Python, how can we find out the command line arguments that were provided for a script, and process them? Related background reading: What does "sys.argv[1]" mean? (What is sys.argv, and ...
34 votes
4 answers
185k views
Command line input in Python [duplicate]
Is it possible to run first the program then wait for the input of the user in command line. e.g. Run... Process... Input from the user(in command line form)... Process...
6 votes
5 answers
16k views
python library for user input
I am implementing a small command line tool in python that needs to ask the user a couple of questions. I use raw_input('Are you male or female?') all the time. Now I would like to be able to deal ...
2 votes
3 answers
4k views
Checking whether the user input is a number [duplicate]
I'm trying to compare a input that the user receives that checks if the input is actually a number. Here's what I have so far: numstring = input("Choose a number between 1 and 10") and then to ...
2 votes
6 answers
11k views
How do I get user input from the keyboard in Python 2? [duplicate]
I wrote a function in Python which prompts the user to give two numbers and adds them. It also prompts the user to enter a city and prints it. For some reason, when I run it in a shell, I get "name is ...
2 votes
1 answer
45k views
Prompt user for file input [duplicate]
I have code that manipulates data of a file that I currently have hard-coded in the script. I want to be able to prompt the user to chose the input file rather than having to hard-code it. Here is ...
0 votes
4 answers
34k views
Read user input numbers and perform a calculation in Python
please help me... "Read in two numbers from user input without a prompt, add them, and print the result. Hint: Use int() to convert the numbers to integers. Note: These activities may test code ...
2 votes
4 answers
20k views
TypeError: 'str' object is not callable with input() [duplicate]
I have the following code, which is supposed to ask the user 2 file names. I get an error with the input() in the second function but not in the first, I don't understand... Here is the error : ...
1 vote
4 answers
6k views
How can I run a python code with input on Linux terminal? [duplicate]
I have a file named myadd.py that contains only the following function: def myadd(a,b): return a+b How can I run it on Linux terminal? I am looking for something easy like this: python myadd 2,3 ...
2 votes
2 answers
13k views
Equivalent of java.util.Scanner in python
In Java, one can write something like this: Scanner scan = new Scanner(System.in); x = scan.nextInt(); y = scan.nextDouble(); etc. What is the equivalent of this in Python 3? The input is a list of ...
-2 votes
2 answers
4k views
How to ask for a file in Python?
I have an interact() function which I need to ask for a file. I already have a function load_maze(filename) which loads my text document in python. How do i get interact() to ask for my filename in ...
0 votes
7 answers
810 views
How to use a function with an input? [duplicate]
Ok so I have a function I've made called DrawGraph. This one function is pretty much my whole program. DrawGraph(x, y, xv, yv, s) At the start of the program I would like to have to type in this ...
2 votes
4 answers
3k views
How do I read from the terminal in Python? [duplicate]
I just want to use os.system("dir") and also be able to save the text outputted to a variable. I tried using sys.stdout.read() but running sys.stdout.readable() returns False. Do you know how I can ...
0 votes
2 answers
4k views
How can I read output from another program? [duplicate]
How can I receive input from the terminal in Python? I am using Python to interface with another program which generates output from user input. I am using subprocess.Popen() to input to the program, ...