You should be able to use
line.strip('\n') and line.strip('\t'). But these don't modify the line variable...they just return the string with the \n and \t stripped. So you'll have to do something likeline = line.strip('\n')
line = line.strip('\t')
That should work for removing from the start and end. If you have
\n and \t in the middle of the string, you need to doline = line.replace('\n','')
line = line.replace('\t','')
to replace the
\n and \t with nothingness.from : https://stackoverflow.com/questions/9347419/python-strip-with-n
No comments:
Post a Comment