第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

沒有output.html文件生成

我用的是是python 3.5版本,打印結(jié)果倒是對的,可是沒有生成output.html文件,哪位大神知道怎么解決嗎?一下是我的代碼:

import sys
class HtmlOutputer(object):
? ?def __init__(self):
? ? ? ?self.datas = []

? ?def collect_data(self, data):
? ? ? ?if data is None:
? ? ? ? ? ?return
? ? ? ?self.datas.append(data)

? ?def output_html(self):
? ? ? ?fout = open('output.html', mode='w', encoding='utf-8')

? ? ? ?fout.write("<html>")
? ? ? ?fout.write("<head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"></head>")
? ? ? ?fout.write("<body>")
? ? ? ?fout.write("<table>")
? ? ? ?count = 0
? ? ? ?for data in self.datas:
? ? ? ? ? ?fout.write("<tr>")
? ? ? ? ? ?fout.write("<td>%d</td>" % count)
? ? ? ? ? ?fout.write("<td>%s</td>" % data['url'])
? ? ? ? ? ?fout.write("<td>%s</td>" % data['title'].encode('utf-8'))
? ? ? ? ? ?fout.write("<td>%s</td>" % data['summary'].encode('utf-8'))
? ? ? ? ? ?fout.write("</tr>")
? ? ? ? ? ?count += 1

? ? ? ?fout.write("</table>")
? ? ? ?fout.write("</body>")
? ? ? ?fout.write("</html>")
? ? ? ?fout.flush()
? ? ? ?fout.close()
? ? ? ?print(sys.getdefaultencoding())



正在回答

1 回答

看有沒有生成權(quán)限。

0 回復 有任何疑惑可以回復我~
#1

且涉煙塵 提問者

這個怎么看呢,請說明下方法,謝謝
2016-04-09 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Python開發(fā)簡單爬蟲
  • 參與學習       227603    人
  • 解答問題       1282    個

本教程帶您解開python爬蟲這門神奇技術(shù)的面紗

進入課程

沒有output.html文件生成

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號