print formate

Discussion in 'Python' started by Gary Wessle, May 5, 2006.

  1. Gary Wessle

    Gary Wessle Guest

    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
     
    Gary Wessle, May 5, 2006
    #1
    1. Advertising

  2. Gary Wessle

    Larry Bates Guest

    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
     
    Larry Bates, May 5, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. aqmaiya

    Convert Date to Short formate

    aqmaiya, Jun 7, 2006, in forum: Python
    Replies:
    2
    Views:
    366
    John Machin
    Jun 7, 2006
  2. keto
    Replies:
    0
    Views:
    1,043
  3. Replies:
    19
    Views:
    681
    Twisted
    Jul 22, 2007
  4. Replies:
    1
    Views:
    522
  5. noydb

    Formate a number with commas

    noydb, Feb 9, 2012, in forum: Python
    Replies:
    8
    Views:
    210
    Terry Reedy
    Feb 10, 2012
Loading...

Share This Page