What is the Python equivalent of Perl\'s chomp function, which removes the last character of a string if it is a newline?
chomp
import re r_unwanted = re.compile("[\n\t\r]") r_unwanted.sub("", your_text)