On 23/05/06, Shuai Jiang <[EMAIL PROTECTED]> wrote:
> Hello,
> I just got Python In a Nutshell and decided to play around with the time
> section. While playing with the calendar module, I encountered a problem:
>
> >>> import calendar
> >>> calendar.calendar (2006)
> '                                  2006\n\n      January
>                February                   March\nMo Tu We Th Fr Sa Su
> Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su\n                   1
>     1  2  3  4  5             1  2  3  4  5\n 2  3  4  5  6  7  8       6  7
[...]
> I can't seem to figure out how to make it look prettier
> Thanks in advance

See those '\n' characters? They mean "start a new line" in some
contexts (such as text output and graphical editors). You can make
python interpret them by asking it to print the output.  For example:

>>> s = 'Hello\n   World!\n---------\n ------- \n  -----  \n'
>>> s
'Hello\n   World!\n---------\n ------- \n  -----  \n'
>>> print s
Hello
   World!
---------
 -------
  -----

>>>

Or, you could try typing "print calendar.calendar(2006)" into your console :-)

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to