remove newline characters from string python code example
Example 1: python removing \n from string
line = line.strip('\n')
line = line.strip('\t')
Example 2: remove n from string python
a_string = a_string.rstrip("\n")
Example 3: python how to remove n from string
mylist = []
# Assuming that you have loaded data into a lines variable.
for line in lines:
mylist.append(line.strip().split('\t')