Sunday, January 25, 2015

[solved]How to let python detect the line break / endline when reading lines in files

Simple. Use splitlines()
L = open("myFile.txt", "r").read().splitlines();
for line in L: 
    process(line) # this 'line' will not have '\n' character at the end
shareedit

No comments:

Post a Comment