继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

python 报错

慕斯卡3302699
关注TA
已关注
手记 271
粉丝 58
获赞 314


在网络怕爬虫过程中遇到,编码错误
'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')


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP