python read lines remove code example
Example 1: stripping /n in a readlines for a pytgon file
alist = [line.rstrip() for line in open('filename.txt')]
Example 2: readlines replace \n
with open(filename) as f:
mylist = f.read().splitlines()
alist = [line.rstrip() for line in open('filename.txt')]
with open(filename) as f:
mylist = f.read().splitlines()