reading stdinput
Neil Schemenauer
nas at arctrix.com
Sat Mar 17 22:30:54 EST 2001
On Sun, Mar 18, 2001 at 11:11:00AM +0930, Michael Hall wrote:
> How do I read standard input into a Python script? I'm trying to do the
> same as 'read' in a shell script to create a variable. I've played about
> with various combinations of 'sys.stdin.read()' and such but no go.
You haven't defined your problem very well. sys.stdin.read()
will indeed read from stdin. Perhaps you want
sys.stdin.readline() or raw_input()? For example:
x = raw_input("Your name: ")
print "Hello", x
Cheers,
Neil
More information about the Python-list
mailing list