print formate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Wessle

    #1

    print formate

    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(patt ern, 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
  • Larry Bates

    #2
    Re: print formate



    Gary Wessle wrote:[color=blue]
    > 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(patt ern, 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[/color]

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

    -Larry Bates

    Comment

    Working...