User input question
Eric Brunel
eric.brunel at pragmadev.com
Thu May 30 07:17:03 EDT 2002
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...
HTH
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list