paste text with newlines into raw_input?

half.italian at gmail.com half.italian at gmail.com
Wed May 30 23:15:22 EDT 2007


On May 30, 2:04 pm, BartlebyScrivener <bscrivene... at gmail.com> wrote:
> Using Python on Debian Etch.
>
> What is the best way to paste a block of text in at the command
> prompt.
>
> I'm trying something like:
>
> Quote = raw_input("Paste quote here: ")
>
> Which works great for one line of text with a single newline. It gets
> stripped. Okay.
>
> Is there a way to paste in a block of text that has multiple lines and
> newlines? I don't care if they all get stripped in the process, in
> fact I'd prefer it. I've used strip before, but that doesn't seem to
> work until you get the text into the program.
>
> Thanks for any help.
>
> Rick

import sys
s =sys.stdin.read()
print s

which will read until ctrl-d

~Sean




More information about the Python-list mailing list