Getting rid of \n when using .readlines() [duplicate]

This should do what you want (file contents in a list, by line, without \n)

with open(filename) as f:
    mylist = f.read().splitlines() 

Leave a Comment