How-to create a Pascal Record using Python
Daniel
Daniel.Kinnaer at AdValvas.be
Thu Jan 4 14:05:33 EST 2001
Hello,
How are Pascal-records used in Python? I've tried some code (below)
but I ran into trouble with this '\012' attached to each line. Can
someone please help me out? What is the correct way of
using/creating/writing/reading Pascal-records in Python? Thanks
Daniel
"""
This is the contents of the records-file (Each line is a record
containing 3 elements.)
aaa,12,azert
bbb,a1,qsdfg
ccc,2c,wxcvb
ddd,7f,yuiop
eee,9b,hjklm
fff,0e,nhyuj
"""
#define a function which stores all the lines from a file into a list
def getTheLines(filename):
file = open(filename)
return map(str, file.readlines())
#store contents of records-file into a list
lijst = getTheLines( "C:\\Python20\\AProject\\Records\\records.txt")
print lijst
The output is as follows :
['aaa,12,azert\012', 'bbb,a1,qsdfg\012', 'ccc,2c,wxcvb\012',
'ddd,7f,yuiop\012', 'eee,9b,hjklm\012', 'fff,0e,nhyuj']
More information about the Python-list
mailing list