python strip empty lines code example
Example 1: python strip newline from string
a_string = a_string.rstrip("\n")
Example 2: remove empty lines from file python
with open("new_file","r") as f:
for i in f.readlines():
if not i.strip():
continue
if i:
print i,