remove line breaks python code example
Example 1: python removing \n from string
line = line.strip('\n')
line = line.strip('\t')
Example 2: python strip newline from string
a_string = a_string.rstrip("\n")
Example 3: python remove new line
lines = ("line 1 \r\n")
lines.rstrip("\n\r")
Example 4: python replace newline
without_line_breaks = a_string.replace("\n", " ")
Example 5: python replace newline
from tika import parser
filename = 'myfile.pdf'
parsedPDF = parser.from_file(filename)
pdf = parsedPDF["content"]
pdf = pdf.replace('\n\n', '\n')
print (pdf)