python - Remove last elf from file -
I want to remove eol (the end of the line and empty rows) from a file I
problem The input file is ending with text and EOL I am trying to delete EOL from the file after writing a text file as a list of words, many lines may end with an empty line or \ n
Input file
It is testing the word list with returns in the word list
Source code
Open file name = "input_file.txt" (file name, 'r') as FN form: fn For file in line: = '\ n': x = line print x, with opening # (file name, 'w') foo: # foo.write (x)
Thanks to any suggestions and discussion, the whole content is more effective than strip - it does not keep the whole file contents in memory - so it will be fine for large files This code does the blank lines buffers and when we open the blank line If not, then only prints them, so, in the last blank lines Drit will not.