美文网首页我爱编程
Python 输出到excel

Python 输出到excel

作者: eryk_yang | 来源:发表于2018-04-12 15:55 被阅读0次

使用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)

相关文章

网友评论

    本文标题:Python 输出到excel

    本文链接:https://www.haomeiwen.com/subject/ivffkftx.html