Reading them into a list is trivially done with readlines():
f = open('your-file.dat')
yourList = f.readlines()
If you need a new line, you can use the ars method or do:
yourList = [line.rstrip('\n') for line in f]
If you need a dictionary with keys from 1 to the length of the list, the first way that comes to mind is to make a list as described above, and then do:
yourDict = dict(zip(xrange(1, len(yourList)+1), yourList))
source
share