how to remove xef xbb xbf?
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() .