Python Forum
How do I accept input from the terminal when I execute my file? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How do I accept input from the terminal when I execute my file? (/thread-1151.html)



How do I accept input from the terminal when I execute my file? - cocoa1231 - Dec-08-2016

I've been trying to figure this out for a while now.
When I execute my file using python file.py, how can I send input like this: python file.py inputstring?


RE: How do I accept input from the terminal when I execute my file? - Larz60+ - Dec-08-2016

name = input('Please enter your name: ')
# for python 2.7 use rawinput()
from command line, place variables after script name, and read in with argv: http://stackoverflow.com/questions/1009860/command-line-arguments-in-python