Try the string.translate function, with an identity translator (created by string.maketrans), and a list of chars to delete (here you put CR and LF). This will probably be the fastest option.