User input question

Ken ken at hotmail.com
Thu May 30 05:57:14 EDT 2002


"Eric Brunel" <eric.brunel at pragmadev.com> wrote in message
news:ad4qbk$sd6$1 at wanadoo.fr...
> Ken wrote:
> [snip]
> > This is the equilvalent C++ code I want to work in python:
> >
> > string s;
> > cin>>s;
> > search_word(s)
> >
> > void search_word(string s){
> >   //do something
> > }
>
> Considering your HTML form, I don't know if it's the right thing to do,
but
> here is the exact equivalent of your C++ code:
>
> import sys
> s = sys.stdin.readline()
> search_word(s)
>
> The method "readline" on an opened file object reads one line in the file,
> which, IIRC, is the same than doing "cin >>" in C++.
>
> But considering what I know about HTML forms (but I've forgotten a
lot...),
> you may get the string "searchword=<word>" instead of just the word you
> want...
>

Does this also work for user input from keyboard?

Thanks





More information about the Python-list mailing list