我爱编程

Python 输出到excel

2018-04-12  本文已影响0人  eryk_yang

使用xlsxwrite包

save_path ='C:\\Users\\yangergou\\Desktop\\code\\toutiao_news.xlsx'

wk = xlsxwriter.Workbook(save_path)

sheet = wk.add_worksheet('news')

title = ['title','media_name','categories','keywords','item_id','article_url','gallary_image_count'

        ,'comment_count','has_image','has_video','hot']

sheet.write_row('A1',title)

# write_column(r,c,content)  r: 按列写入的开始行;c: 按列写入的写入列;content : 写入的内容(list)

sheet.write_column(1,0,title)

sheet.write_column(1,1,media_name)

sheet.write_column(1,2,categories)

sheet.write_column(1,3,keywords)

sheet.write_column(1,4,item_id)

sheet.write_column(1,5,article_url)

sheet.write_column(1,6,gallary_image_count)

sheet.write_column(1,7,comment_count)

上一篇下一篇

猜你喜欢

热点阅读