doc = open("1.html").read().strip()
doc = doc.decode("utf-8","ignore")
this example is OK. I can get the right unicode string doc.
doc = open("1.html").read().strip()
if u"charset=utf" in doc or u"charset=\"utf" in doc:
doc = doc.decode("utf-8","ignore")
there is error "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 289: ordinal not in range(128)" Anyone can explain this? the string doc can be changed by string find? forgot to say,the 1.html contain the chinese word.