课程
/后端开发
/Python
/Python开发简单爬虫
输出不了中文
2017-09-28
源自:Python开发简单爬虫 7-6
正在回答
已经解决
win7 python3.6 遇到乱码的情况
同明磊
只需要在fout = open('output.html', 'w', encoding = 'utf-8')
fout.write("<td>%s</td>" % data['title'])
fout.write("<td>%s</td>" % data['summary'])
这里面不能加.encode('utf-8'),加了会乱码
fout.write("<head><meta charset = 'utf-8'></head>")这个写不写无所谓,不影响
fout.write('<td>%s</td>' % data['title'].encode('utf-8')) fout.write('<td>%s</td>' % data['summary'].encode('utf-8')) #改为 fout.write('<td>%s</td>' % data['title']) fout.write('<td>%s</td>' % data['summary']) 数据本身已经编码过了,不需要再次编码了
举报
本教程带您解开python爬虫这门神奇技术的面纱
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号