- 博客(2)
- 收藏
- 关注
原创 python bytes和str转换 以及 chardet模块
在练习python爬虫遇到的问题记录一下,请求到网页数据为Bytes编码类型,在用decode转换utf8时出现了报错search了一下^.^,decode解码方式是有可能报错的#string = b.decode()#第一参数默认utf8,第二参数默认strict#print(string)#string = b.decode('utf-8','ignore')#忽略非法字符,用strict会抛出异常#string = b.decode('utf-8,'replace')#用?取代.
2022-02-28 15:56:20
561
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人