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

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

我把html_output這個(gè)文件修改了下,就提示我AttributeError: 'HtmlOutputer' object has no attribute 'save_excel'

# -*-coding:UTF-8-*-
import xlsxwriter

class HtmlOutputer(object):
? ?def __init__(self): ?# 建立列表存放數(shù)據(jù)
? ? ? ?self.datas = []

? ?def collect_data(self,data): ?# 收集數(shù)據(jù)
? ? ? ?if data is None:
? ? ? ? ? ?return
? ? ? ?self.datas.append(data)

? ?def save_excel(self):
? ? ? ?book = xlsxwriter.Workbook(r'C:\Users\Administrator\Desktop\abc.xlsx') #默認(rèn)儲(chǔ)存在桌面
? ? ? ?tmp = book.add_worksheet() #建立sheet
? ? ? ?row_num = 11 #行號
? ? ? ?for data in self.datas:
? ? ? ? ? ?for i in range(1, 11):
? ? ? ? ? ? ? ?tag_pos1 = 'A%s' % i
? ? ? ? ? ? ? ?tmp.write(tag_pos1,data['url'])
? ? ? ? ? ? ? ?tag_pos2 = 'B%s' % i
? ? ? ? ? ? ? ?tmp.write(tag_pos2,data['title'])
? ? ? ? ? ? ? ?tag_pos3 = 'C%s' % i
? ? ? ? ? ? ? ?tmp.write(tag_pos3,data['summary'])
? ? ? ?book.close()

代碼如上,我的類里明明已經(jīng)定義了這個(gè)方法,求大佬指教,我用的是pycharm,第三方模塊已經(jīng)全部導(dǎo)入了

正在回答

1 回答

你的save_excel是方法,先在你調(diào)用的類里面, 把HtmlOutputer這個(gè)對象生成了

self.outputer = html_outputer.HtmlOutputer()

然后 outputer.save_excel()?
注意excel加括號

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

金至則城 提問者

可能是以前編譯的pyc文件有望問題
2017-02-22 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

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

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

進(jìn)入課程

我把html_output這個(gè)文件修改了下,就提示我AttributeError: 'HtmlOutputer' object has no attribute 'save_excel'

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

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

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