課程
/后端開(kāi)發(fā)
/Python
/Python開(kāi)發(fā)簡(jiǎn)單爬蟲(chóng)
title 和 summary部分均亂碼
2018-03-19
源自:Python開(kāi)發(fā)簡(jiǎn)單爬蟲(chóng) 7-7
正在回答
非常感謝大神
看了下面的評(píng)論解決了:
fout.write("<td>%s</td>" % data['title'].encode('utf-8'))fout.write("<td>%s</td>" % data['summary'].encode('utf-8'))這兩句不需要encode('utf-8'),加了這個(gè)title和summary就變成十六進(jìn)制顯示的字符了。需要在這一句fout = open('output.html', 'w', encoding='utf-8')加上encoding='utf-8'
慕姐2004059
Bukrs
舉報(bào)
本教程帶您解開(kāi)python爬蟲(chóng)這門(mén)神奇技術(shù)的面紗
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2019-04-29
非常感謝大神
2018-03-20
看了下面的評(píng)論解決了:
fout.write("<td>%s</td>" % data['title'].encode('utf-8'))
fout.write("<td>%s</td>" % data['summary'].encode('utf-8'))
這兩句不需要encode('utf-8'),加了這個(gè)title和summary就變成十六進(jìn)制顯示的字符了。需要在這一句fout = open('output.html', 'w', encoding='utf-8')加上encoding='utf-8'