| Store | Cart

Reading from stdin

From: Skip Montanaro <s...@pobox.com>
Wed, 10 Mar 2004 09:14:14 -0600
    Colin> However, I want the python script to print out the numbers as it
    Colin> gets them, since there could be hours/days between numbers - not
    Colin> a very efficient C program :). Actually, I would like to
    Colin> read-a-line/ print-a-line/ read-a-line/etc

    Colin> I have tried things like 'sys.stdin.read*' with no success.

Have you tried this?

    import sys
    for line in sys.stdin:
        print line.strip()


Recent Messages in this Thread
C GIllespie Mar 10, 2004 02:56 pm
Skip Montanaro Mar 10, 2004 03:14 pm
Christian Vogel Mar 10, 2004 03:20 pm
C GIllespie Mar 10, 2004 05:36 pm
P...@draigBrady.com Mar 11, 2004 11:03 am
Messages in this thread