cin

Dr. Peter Stoehr peter.stoehr at weihenstephan.org
Thu Jul 22 15:11:44 EDT 1999


Hi everyone,

"Michael P. Reilly" wrote:
> 
> Joacim L*wgren <fire at netlimit.com> wrote:
> : Hi,
> 
> : I'm new to Python and I'm wondering what the C++ "cin" (or C
> : "scanf()")equivalent in Python is. Doesn't seem there's a quick function for
> : this.
> 
> Actually it is not a function, it is an operation (%).
> 
> >>> name, age = 'Michael', 30
> >>> s = 'My name is %s and I am %d years old.'
> >>> print s % (name, age)
> My name is Michael and I am 30 years old.
> 
> Take a look at the Library Reference Manual, Section 2.1.5.1 "More String
> Operations" (http://www.python.org/doc/current/lib/typesseq-strings.html).
> 
>   -Arcege

this emulates the C-function sprintf and not scanf.
What Joacim is looking for is something like raw_input :-)

# -----------------------------------------
aString = raw_input("Give me input :")
print aString
# -----------------------------------------

Greetings from Erding/Bavaria/Germany/Europe/Earth/Universe
    Peter	
-- 
---------------------------------------------------------------------------
   Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232
---------------------------------------------------------------------------
		I'm the terror that flaps in the night




More information about the Python-list mailing list