heres a dumb question....
Jeremy Bush
zombor_666 at hotmail.com
Mon Feb 4 23:51:51 EST 2002
"Jason Orendorff" <jason at jorendorff.com> wrote in message
news:mailman.1012873689.8841.python-list at python.org...
> Jeremy Bush writes:
> > [...] cant seem to figure out how to get keyboard input...
> > ive read the whole readme that came with it, the tutorial,
> > everything.
>
> raw_input() gets a line of input.
>
> Unlike C++, you ordinarily get a line at a time, and split it
> to get the information you want.
>
> For example, if you expect the user to type in numbers
> separated by commas, you'd do:
>
> line = raw_input('> ') # see? you can provide a prompt
> fields = line.split(',')
> for s in fields:
> x = float(s) # convert string to float
> print "you entered the number:", x
>
> If you "import sys", then you have sys.stdin, which is a file object.
> File objects have various methods for input. Viz:
> http://www.python.org/doc/current/lib/bltin-file-objects.html
>
> Enjoy Python!
>
> ## Jason Orendorff http://www.jorendorff.com/
>
>
Thanks, everyone
More information about the Python-list
mailing list