get a liste from a txt file python

text_file = open("filename.dat", "r")
lines = text_file.readlines()
print lines
print len(lines)

Here is what the above code is Doing:
1. It opens the file “filename.dat” for reading.
2. It reads the entire contents of the file into a list called “lines”.
3. It prints the contents of the list.
4. It prints the length of the list.
5. It closes the file.

Note that the readlines() function returns a list of strings, one string for each line in the file.