python把数据保存到excel,python读取excel并在以后的数据上添加

  python把数据保存到excel,python读取excel并在以后的数据上添加

  注意事项:

  1、模块xlwt适合写入电子表格文档格式的超过

  2、模块安装适合文件格式格式的超过写入

  3、使用xlwt写入文件格式格式的超过时,excel可能无法打开

  4、使用xlwt以0行开始,使用安装以一行开始

  importrequestsfrombs 4 importbeautifulsouimportxlwtdefrequest _ douban(URL):try:headers={ accept 3360 t exchaders q=0.8,APP /信号交换;v=b3q=0.9 ,接受-编码: gzip,deflate,br ,接受-语言: zh-CN,zh;q=0.9 ,连接: Keep-Alive , Host: movie.douban.com , user-agent 3360 Mozilla wwa x64)apple WebKit/537.36(khtml,像壁虎一样)chrome/91。0 .4472 .101 safari/537.36 }响应=请求。get))UUUE超时=3)if响应。status _ code==200:返回响应。请求除外.find(class_=grid_view ).find _ all( Li )book=xlwt。workbook)编码= utf-8 syle _ compress iok eet。写)、 0 、 0 、"排名"(sheet.write ) 0、3、评分"(sheet.write ) 0、4、作者"(sheet.write ) 0、5 个人资料(I=1 for item inlist:item _ name=item。查找(class _= title ).stringitem _ img=item。find) _ score=item。find)class _= rating _ num ).stringitem)。text item _ intr=item。find(class _= inq )。字符串表。write(I,0,item_name ) shet.write ) I,1,1 item_intr ) i=1 book.save(u ) u 豆瓣最大的start= str(page * 25)filter= lxml=request _ douban)URL)souban

  importopenpyxlasopenpyxlimportrequestsfrombs 4 importbeautifulousouflomopenpyxlimportworkbookfromopenpyxl。utilsimportget _ coll:headers={ accept : text/html,application/xhtml xml,application/XML;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,APP /信号交换;v=b3q=0.9 ,接受-编码: gzip,deflate,br ,接受-语言: zh-CN,zh;q=0.9 ,连接: Keep-Alive , Host: movie.douban.com , user-agent 3360 Mozilla wwa x64)apple WebKit/537.36(khtml,像壁虎一样)chrome/91。0 .4472 .101 safari/537.36 }响应=请求。get))UUUE超时=3)if响应。status _ code==200:返回响应。请求除外.find(class_=grid_view ).find _ all( Li )book=Workbook)sheet=book。活动工作表值=名称)列=3,值=排名)shalue列=5,值=作者)工作表.单元格(行=1,列=6,值=简介(前言)item_index=item.find(class_= ).stringitem _ score=item。find)class _= rating _ num ).字符串itittid .text item _ intr=item。find(class _= inq )。字符串表。cell(row=I,column=1,value=item _ name))value 652 value=item _ img(sheet。单元格(行=I,列=3,值=item _ index)工作表。cell)row=I,column=value=item _ intr)I=1本书。保存(u)u 豆瓣最受欢迎的250部电影. xls保存开始= str(page * 25)filter= lxml=reqml

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: