- 帖子
- 6
- 精华
- 0
- 积分
- 35
- 阅读权限
- 10
- 注册时间
- 2017-12-7
- 最后登录
- 2018-1-10
|
TED 发表于 2017-12-18 16:12
content = web.read().decode('utf-8') 试下,把bytes转化为unicode
还是不行- RESTART: C:/Users/lenovo/AppData/Local/Programs/Python/Python37-32/asfdgggfdsfgghsf.py
- Traceback (most recent call last):
- File "C:/Users/lenovo/AppData/Local/Programs/Python/Python37-32/asfdgggfdsfgghsf.py", line 12, in <module>
- out.write(data)
- UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 27363: illegal multibyte sequence
- >>>
- [code]import urllib.request
- url=('http://www.baidu.com')
- web=urllib.request.urlopen(url)
- content=web.read().decode('utf-8')
- data=content
- out=open('C:/Users\lenovo\Desktop\youyouyou\shiyan.html','w')
- out.write(data)
- out.close()
复制代码 [/code] |
|