Question: how to remove xef xbb xbf?
Answer: The \xef\xbb\xbf is a Byte Order Mark for UTF-8 - the \x is an escape sequence indicating the next two characters are a hex sequence representing the character code. The \n is a new line character. To remove this, you can use rstrip() .