There are several methods to do this I am discussing a few with you:
Use rstrip
>>> 'test string\n'.rstrip()
'test string'
To use this for newlines:
>>> 'test string \n \r\n\n\r \n\n'.rstrip('\n')
'test string \n \r\n\n\r '
You can also use lstrip() and strip()
>>> s = " \n\r\n \n abc def \n\r\n \n "
>>> s.strip()
'qwe rty'
>>> s.lstrip()
'qwe rty \n\r\n \n '
>>> s.rstrip()
' \n\r\n \n qwe rty'