i see a string in this code:
data[:2] == '\xff\xfe'
i don't know what '\xff\xfe' is,
so i want to escape it ,but not successful
import cgi print cgi.escape('\xff\xfe')#print \xff\xfe
how can i get it.
You cannot escape or encode an invalid string.
You should understand that you are working with strings and not byte streams and there are some characters you cannot accept in them, first of them being
So if you need to include non-valid strings characters (unicode or ascii) you will have to stop using strings for this.
Take a look at PEP-0358
'\xFF' means the byte with the hex value FF. '\xff\xfe' is a byte-order mark: http://en.wikipedia.org/wiki/Byte%5Forder%5Fmark
You could also represent it as two separate characters but that probably won't tell you anything useful.
What is the connection between "i don't know what '\xff\xfe' is" and "so i want to escape it"? What is the purpose of "escaping" it?
It would help enormously if you gave a little more context than