[Tutor] How to print out multiple lines

Sheila King sheila@thinkspot.net
Sun, 07 Jan 2001 13:30:24 -0800


Replying to my own post:

OK, it seems simple enough to accomplish this in the IDLE environment or at a
command line prompt:

>>> print '''Hello.
... How are you?
... Fine.
... Thanks for asking.'''
Hello.
How are you?
Fine.
Thanks for asking.
>>>


Just use triple quotes.

But, how do I accomplish something like this (here is a small SMTP script I
wrote for investigation):

import smtplib, string

servername=input("SMTP server name: ")
Fromaddress=input("From address: ")
Toaddress=input("To address: ")
MessageText=input("message text: ")
server=smtplib.SMTP(servername)
server.sendmail(Fromaddress, Toaddress, MessageText)
server.quit()

The above script will not allow MessageText to have multiple lines.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/

On Sun, 07 Jan 2001 13:05:55 -0800, Sheila King <sheila@thinkspot.net>  wrote
about [Tutor] How to print out multiple lines:

:OK, I've been to python.org, I've gone through Guido's tutorial, I've looked
:at a few modules.
:
:I've even been able to sort of send mails through a SMTP server and retrieve
:articles off of an NNTP server. So I have *some* clue.
:
:But apparently not enough.
:
:How can I get an interactive Python session to read in something like this:
:
:------------------------------
:Hello.
:How are you?
:I'm fine.
:Thanks for asking.
:------------------------------
:
:So that the newline characters are preserved, and when I print them out, they
:are printed to the screen?
:
:When I retrieved the news articles off the NNTP server, for instance, the
:message body was just one big long string, with some numeric code for the
:newlines. It was just a mess to read.