摘要:
法一:isinstance(s, str) 用来判断是否为一般字符串isinstance(s, unicode) 用来判断是否为unicode或if type(str).__name__!="unicode":str=unicode(str,"utf-8")else:pass法二:Python chardet 字符编码判断使用 chardet 可以很方便的实现字符串/文件的编码检测。尤其是中文网页,有的页面使用GBK/GB2312,有的使用UTF8,如果你需要去爬一些页面,知道网页编码很重要的,虽然HTML页面有charset标签,但是有些时候是不对的。 阅读全文
posted @ 2011-03-02 02:36
dkcndk
阅读(80764)
评论(1)
推荐(2)