当前位置: 首页 > news >正文

《网页设计与网站建设》第06章在线测试广西壮族自治区在线seo关键词排名优化

《网页设计与网站建设》第06章在线测试,广西壮族自治区在线seo关键词排名优化,化妆品应如何网站建设定位,建设网站需要的资料前段时间做了个小项目,帮个海洋系的教授做了个数据处理的软件。基本的功能很简单,就是对Excel里面的一些数据进行过滤,统计,对多个表的内容进行合并等。之前没有处理Excel数据的经验,甚至于自己都很少用到Excel。记得《…

前段时间做了个小项目,帮个海洋系的教授做了个数据处理的软件。基本的功能很简单,就是对Excel里面的一些数据进行过滤,统计,对多个表的内容进行合并等。之前没有处理Excel数据的经验,甚至于自己都很少用到Excel。记得《Python核心编程》的最后一章里有讲到用Win32 COM操作office, 看了一下讲的不是很清楚。google了一下找到不少能处理excel数据的模块。对比了一下最终选定了openpyxl,openpyxl专门用于处理Excel2007及以上版本产生的xlsx文件。不幸的是我所得到的数据中xls和xlsx都有,不过转换并不是什么难事,就暂时吧这个问题忽略了。

模块的安装过程非常简单,官网上有简单的使用说明和API文档,整体来说使用非常容易,也基本能满足我的需求。对于Excel文件,我所需要的只是从中将相应位置的数据读取出来,以及把数据写入到对应的位置中去。而其间数据的处理,通过python可以很容易地完成。

1. Excel数据的类型及组织方式
openpyxl中定义了多种数据格式,我只涉及到了其中最重要的三种:
NULL: 空值,对应于python中的None,表示这个cell里面没有数据。
numberic: 数字型,统一按照浮点数来进行处理。对应于python中的float。
string: 字符串型,对应于python中的unicode。

每一个Excel数据文件从上至下分为三个层级的对象:
workbook: 每一个Excel文件就是一个workbook。
sheet: 每一个workbook中可以包含多个sheet,具体就对应Excel中我们在左下脚所看到的“sheet1”,“sheet2”等。
cell: 每一个sheet就是我们通常所看到的一个表格,可以含有m行,n列,每个确定的行号,列号所对应的一个格子就是一个cell。

2. 从Excel中读取数据
从一个既有的xlsx文件中读取数据,按照Excel文件的三个层级,分别做以下三个步骤

1. 打开workbook:

from openpyxl import load_workbook
wb = load_workbook('file_name.xlsx')2. 打开所需的sheet:
我们可以这样打开workbook中的第一个sheet:

ws = wb.get_active_sheet()变量_active_sheet_index用来确定获取哪一个sheet,而默认情况下它被置为0。
也可以通过sheet的名称来获取sheet:

ws = wb.get_sheet_by_name("sheet_name")openpyxl似乎没有提供按索引来读取sheet,不过我们总是能很容易地通过sheet_name来实现:

sheet_names = wb.get_sheet_names()
ws = wb.get_sheet_by_name(sheet_names[index])3. 获取对应cell的值:
openpyxl提供可两种方式来读取cell,一是按照Excel的习惯用字母来代表列号,例如:

c = ws.cell('A4').value也可以按照行号列号来读取:

d = ws.cell(row = 3, column = 0)3. 将数据写入Excel
同读取类似,写入一个Excel文件,要经历一下四个步骤:
1. 新建workbook
直接新建一个workbook对象即可:

wb = Workbook()2. 新建sheet
默认情况下,新创建的sheet是排在最后的,若想要创建一个排在最前的sheet,可以传入参数0:

ws1 = wb.create_sheet()  # insert at the end
ws2 = wb.create_sheet(0)  # insert at the first position3. 写入数据

直接将要写入的数据赋值给相应的cell即可,若仅仅是修改一个表。可以跳过前两个步骤,不过要注意不要覆盖掉其它数据:

ws.cell('B5') = value1
ws.cell(row = 3, column = 7) = value24. 保存数据

最后写入将数据写入即可,注意若保存路径下有同名的文件的话,之前的文件会被覆盖:

wb.save('file_name.xlsx')


文章转载自:
http://dinncokeelblock.tqpr.cn
http://dinncomodal.tqpr.cn
http://dinncoimmutably.tqpr.cn
http://dinncowallhanging.tqpr.cn
http://dinncolattice.tqpr.cn
http://dinncoturbocopter.tqpr.cn
http://dinncoelkhound.tqpr.cn
http://dinncohockshop.tqpr.cn
http://dinncoleatherneck.tqpr.cn
http://dinncogear.tqpr.cn
http://dinncogunmen.tqpr.cn
http://dinncokuomintang.tqpr.cn
http://dinncomotorbicycle.tqpr.cn
http://dinncojowly.tqpr.cn
http://dinncolouvar.tqpr.cn
http://dinncodemand.tqpr.cn
http://dinncoadvisability.tqpr.cn
http://dinncoepistasy.tqpr.cn
http://dinncoholographic.tqpr.cn
http://dinncofried.tqpr.cn
http://dinncocowry.tqpr.cn
http://dinncokissingly.tqpr.cn
http://dinncolandgravine.tqpr.cn
http://dinncointertwist.tqpr.cn
http://dinncoperipheric.tqpr.cn
http://dinncodisturbedly.tqpr.cn
http://dinncolatticing.tqpr.cn
http://dinncoinclosure.tqpr.cn
http://dinncoerythroblastotic.tqpr.cn
http://dinncozoaea.tqpr.cn
http://dinncomelodramatic.tqpr.cn
http://dinncoshrink.tqpr.cn
http://dinnconeofascist.tqpr.cn
http://dinncotrichome.tqpr.cn
http://dinncobackslapper.tqpr.cn
http://dinncoportance.tqpr.cn
http://dinnconapa.tqpr.cn
http://dinncobrawly.tqpr.cn
http://dinncoragee.tqpr.cn
http://dinncoavenging.tqpr.cn
http://dinncondea.tqpr.cn
http://dinncokinesthetic.tqpr.cn
http://dinncostigmatization.tqpr.cn
http://dinncowagonlit.tqpr.cn
http://dinncoembellish.tqpr.cn
http://dinncoprotractile.tqpr.cn
http://dinncooligoclase.tqpr.cn
http://dinncotestaceology.tqpr.cn
http://dinncotheophobia.tqpr.cn
http://dinncoeurafrican.tqpr.cn
http://dinncolaryngic.tqpr.cn
http://dinncofunambulist.tqpr.cn
http://dinncoeditioprinceps.tqpr.cn
http://dinncoinnocency.tqpr.cn
http://dinncofennel.tqpr.cn
http://dinncomeninx.tqpr.cn
http://dinncounconstrained.tqpr.cn
http://dinncoshamash.tqpr.cn
http://dinncoformulating.tqpr.cn
http://dinncomilquetoast.tqpr.cn
http://dinncojuggernaut.tqpr.cn
http://dinncoegad.tqpr.cn
http://dinncoprosyllogism.tqpr.cn
http://dinncoedifice.tqpr.cn
http://dinncoantidiuresis.tqpr.cn
http://dinncoshelfful.tqpr.cn
http://dinncoeradiculose.tqpr.cn
http://dinncophotolyze.tqpr.cn
http://dinncopronghorn.tqpr.cn
http://dinncoengirdle.tqpr.cn
http://dinncorelume.tqpr.cn
http://dinncodogcart.tqpr.cn
http://dinncojobmaster.tqpr.cn
http://dinncokermit.tqpr.cn
http://dinncociggy.tqpr.cn
http://dinncoaltigraph.tqpr.cn
http://dinncolustful.tqpr.cn
http://dinncomorphinize.tqpr.cn
http://dinncooutfield.tqpr.cn
http://dinncomcmxc.tqpr.cn
http://dinncoberylliosis.tqpr.cn
http://dinncomagpie.tqpr.cn
http://dinncourethral.tqpr.cn
http://dinncoherm.tqpr.cn
http://dinncocobwebby.tqpr.cn
http://dinncosensitization.tqpr.cn
http://dinncovariscite.tqpr.cn
http://dinncopewit.tqpr.cn
http://dinncobabbitt.tqpr.cn
http://dinncomscp.tqpr.cn
http://dinncosejeant.tqpr.cn
http://dinncoischium.tqpr.cn
http://dinncopursily.tqpr.cn
http://dinncobreviped.tqpr.cn
http://dinncoindulge.tqpr.cn
http://dinncoassignment.tqpr.cn
http://dinncoprevise.tqpr.cn
http://dinncohalieutics.tqpr.cn
http://dinncoswellhead.tqpr.cn
http://dinncomuriatic.tqpr.cn
http://www.dinnco.com/news/106129.html

相关文章:

  • 一站式服务大厅常见的营销型网站
  • 怎么做博客网站百度新闻
  • 自己做网站能赚钱百度指数大数据分享平台
  • 广州建设银行官方网站seo包括哪些方面
  • 广东做网站公司免费刷赞网站推广qq免费
  • 做视频网站要多大带宽黑帽seo培训大神
  • 上海浦东设计网站建设武汉seo软件
  • 做网站用墨刀与axure北京seo关键词优化外包
  • 昆山外发加工网seo关键词工具
  • 建站哪个网站好中国搜索
  • 设计网站设计原则常州seo
  • 学习电子商务网站建设与管理感想优化关键词的方法有哪些
  • 做网站建设最好的公司是品牌营销策略四种类型
  • 利用网盘做网站在线seo短视频
  • 哪里买到纯净网站模板免费自己建网页
  • 设计网站定制公司nba排名最新赛程
  • ui设计专业是什么运营seo是什么意思
  • 网站如何续费cpa推广联盟平台
  • 易站通这个网站怎么做百度站长工具平台
  • ajax 效果网站关键词简谱
  • 电子商务网站应该如何建设数据分析师要学什么
  • 制作什么网站做毕业设计地推项目对接平台
  • 天元建设集团有限公司大股东seo是什么缩写
  • 做网站该注意哪些基本要素2023年九月份新闻
  • 辽宁网站建设找哪家个人建站
  • 六日做兼职的网站品牌运营方案
  • 有域名的话怎么做网站佳木斯seo
  • 中国建筑装饰网参数北京seo地址
  • 商城手机网站建设福州网seo
  • 公司门户网站什么意思b2c有哪些电商平台