python 读写网页内容的时候遇错问题
来源:互联网 发布:淘宝阿尔法下载 编辑:程序博客网 时间:2024/06/05 15:23
url = 'http://www.baidu.com'
try:
response = urllib.request.urlopen(url,timeout=3)
except urllib.error.URLError:
print("网络地址错误:")
exit()
with open('g://baidu.txt','w') as fp:
fp.write(response.read().decode('utf-8'))
报错如下
gbk' codec can't encode character '\xbb' in position 27226: illegal multibyte sequence
解决方式保存方式修改
with open('g://baidu.txt','w',encoding='utf-8') as fp:
fp.write(response.read().decode('utf-8'))
阅读全文
0 0
- python 读写网页内容的时候遇错问题
- [python]抓取网页的内容
- 【python】网页内容抓取遭遇乱码问题
- Python 读取网页内容 乱码问题
- [转]在复制网页内容的时候.加一句…
- Python 爬取鲁东大学贴吧前十页的网页内容
- Python抓取one网页上的内容
- python 截取网页内容
- Python 获取网页内容
- Python抓网页内容
- python抓取网页内容
- python抓取网页内容
- python 网页内容抓取
- Python抓取网页内容
- python 抓取网页内容
- Python抓取网页内容
- 获取网页内容时的乱码问题
- Java网页抓取网页内容时,乱码问题的解决
- MongoDb索引
- "文件包含"预处理命令`include
- 洛谷 1855 榨取kkksc03
- Good Numbers (数位DP)
- Codeforces 101243 F
- python 读写网页内容的时候遇错问题
- Cloudera的CDH和Apache的Hadoop的区别
- JSF实现无刷新二级联动
- iis7无法配置或者无法生存web.config文件
- mybatis最简配置
- 洛谷 1279 字串距离
- POJ 3070 Fibonacci
- Java IO流简介
- C++之STL list解析(3)---《C++ STL》