首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python 报错'gbk' codec can't encode character '\ue5d1' in position 0:

python 报错'gbk' codec can't encode character '\ue5d1' in position 0:

作者头像
学到老
发布2018-03-16 16:41:39
8880
发布2018-03-16 16:41:39
举报

在网络怕爬虫过程中遇到,编码错误

'gbk' codec can't encode character '\ue5d1' in position 0: illegal multibyte sequence
response = requests.get(url)
html_uid = response.text
# name=html_uid["result"]['name']
# path = "E:\\python_py\\景区详情\\省份\\吉林省\\"#文件路径"
file_path =cities_folder+province+city+'_'+str(i)+"_"+str(j)+'.json'
file = open(file_path, 'w')
file.writelines(html_uid)
file.close()

修改部分

file = open(file_path, 'w')增加

encoding='utf-8'

即 file =open(file_path,'w',encoding='utf-8')

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档