Question: How do I format printing in python

Maric Michaud maric at aristote.info
Tue Jun 24 06:57:56 CEST 2008


Le Tuesday 24 June 2008 05:33:01 Larry Bates, vous avez écrit :
> joemacbusiness at yahoo.com wrote:
...
>
> data = '''512 Jun 5 2004 X11r6
> 22 Jan 17 2005 a2p
> 22 Jan 17 2005 acctcom
> 5374 Sep 15 2002 acledit
> 5664 May 13 2004 aclget
> 12020 May 13 2004 aclput
> 115734 Jun 2 2004 adb
> 46518 Jun 4 2004 admin
> 66750 Sep 16 2002 ali
> 1453 Sep 15 2002 alias
> 28150 Jun 4 2004 alog
> 15 May 12 2005 alstat
> '''
>
> for entry in data.rstrip().split('\n'):
>      items = entry.split(' ')
>      print "%-6s     %3s   %2s  %4s    %-7s" % tuple(items)

In python, str objects have a splitlines method for portability it is better, 
a shorthand for split(os.sep).


-- 
_____________

Maric Michaud



More information about the Python-list mailing list