Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > print formate

Reply
Thread Tools

print formate

 
 
Gary Wessle
Guest
Posts: n/a
 
      05-05-2006
Hi


import string
import re
accumulator = []

pattern = '(\S*)\s*(\S*)\s*(\S*)'
for each text file in dir
openfile and read into text
data = re.compile(pattern, re.IGNORECASE).findall(text)
accumulator = accumulator + data
gives a list of tuples which when printed looks like
('jack', 'bony', 'J')
('sam', 'lee', 'S')
....

how can I get the output in the formate
jack bony J
sam lee S
....


thank you
 
Reply With Quote
 
 
 
 
Larry Bates
Guest
Posts: n/a
 
      05-05-2006


Gary Wessle wrote:
> Hi
>
>
> import string
> import re
> accumulator = []
>
> pattern = '(\S*)\s*(\S*)\s*(\S*)'
> for each text file in dir
> openfile and read into text
> data = re.compile(pattern, re.IGNORECASE).findall(text)
> accumulator = accumulator + data
> gives a list of tuples which when printed looks like
> ('jack', 'bony', 'J')
> ('sam', 'lee', 'S')
> ...
>
> how can I get the output in the formate
> jack bony J
> sam lee S
> ...
>
>
> thank you


for entry in list_of_tuples:
print ' '.join(entry)

-Larry Bates
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formate a number with commas noydb Python 8 02-10-2012 03:06 AM
generate report in excel formate surajtheesun@gmail.com Java 19 07-22-2007 09:52 AM
parse the data and generate report in excel formate surajtheesun@gmail.com Java 1 07-17-2007 12:21 PM
Convert Date to Short formate aqmaiya Python 2 06-07-2006 09:17 PM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57