- trim
- rstrip
- chomp
Read file remove newlines
examples/files/read_file_remove_newlines.py
filename = 'examples/files/numbers.txt' with open(filename, 'r') as fh: for line in fh: line = line.rstrip("\n") print(line)
filename = 'examples/files/numbers.txt' with open(filename, 'r') as fh: for line in fh: line = line.rstrip("\n") print(line)