爬百度百科的内容
response=urllib2.urlopen(url)
if response.getcode()!=200:
return None
html=response.read()
return html.decode("UTF-8")
再写入一个文件,写入的时候,出现'gbk' codec can't encode character 'xa0' in position 15
我用的是UTF8编码的东西写入,怎么和gbk有什么关系??
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
请贴上完整代码,和异常信息