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

建设农场网站电商营销策划方案范文

建设农场网站,电商营销策划方案范文,网站做百度推广怎么推广网站,如何做自己的视频网站这里我常用的 python 对于 excel 的读取库有两个,一个是 xlsxwriter 用于操作 excel 的写入,一个是 xlrd 用于 excel 文件的读取。 使用的库的版本如下: xlsx1.2.6xlrd1.1.0 xlsxwriter 写入 excel 新建一个 excel import xlsxwriterpat…

这里我常用的 python 对于 excel 的读取库有两个,一个是 xlsxwriter 用于操作 excel 的写入,一个是 xlrd 用于 excel 文件的读取。

使用的库的版本如下:

  • xlsx==1.2.6
  • xlrd==1.1.0

xlsxwriter 写入 excel

新建一个 excel

import xlsxwriterpath = "/Users/hunter/xxx.xlsx"wb = xlsxwriter.Workbook(path)

添加一个 sheet:

# 定义 sheet 的名称
sheet_name = "sheet_name"  # 添加一个 sheet 页
sheet_1 = wb.add_worksheet(sheet_name)

sheet 表格数据的写入
sheet 的表格数据有几种方式,一种是通过 x, y 这种坐标轴定位的方式,从左上角开始,左上角也就是 ‘A1’ 的位子为 (0, 0)。

比如我们想要在左上角写入数据:

sheet1.write(0, 0, "A1数据")

如果我们想要在第二行,第三列写入数据:

sheet1.write(1, 2, "C2数据")

另一种是通过 excel 的单元格名称来定位写入,比如 ‘A1’,'D4’这种:

sheet1.write("A1", "A1数据")
sheet1.write("F2", "F2数据")

批量写入
除了单个单元格的数据写入,我们还可以通过某个起始单元格来批量写入。

批量写入可以从横向写入,也可以从纵向写入。

比如如果想要从 C2 单元格开始,横向写入 python,java,JS 三条数据,可以如下操作:

sheet1.write_row("C2", ["python", "java", "JS"])

也可以通过 i, j 的定位方式来操作,比如从 “C3” 开始往后写入:

sheet1.write_row(2, 2, ["python", "java", "JS"])

上面的 write_row() 方法是横向写入,从起始位置横向开始写,如果是纵向,那就使用 write_column()

保存
然后将这个 excel 保存:

wb.close()

xlrd 读取 excel

注意: 安装 xlrd 的时候不要安装默认的版本,当前默认的最新版本不能解析 xlsx 文件,我这里选择的是 xlrd==1.0.0

使用 xlrd 从 excel 中读取数据的操作方式如下:

获取 excel

import xlrdpath = "/Users/hunter/xxx.xlsx"
workbook = xlrd.open_workbook(path)

获取 sheet

获取 sheet 对象列表:

sheet_list = workbook.sheets()

获取所有的 sheet 的名称列表:

sheet_name_list = workbook.sheet_names()

根据索引获取单个 sheet:

i = 0
sheet = workbook.sheet_by_index(i)

获取单元格数据
如果直接获取单元格数据,可以通过坐标轴的 x, y 的方式来定位获取,其中左上角是 (0, 0)。

比如我们想获取 (0, 0) 位子的数据,也就是 ‘A1’ 的单元格,我们可以:

cell = sheet.cell(0, 0)

获取到的是这个单元格对象,如果想要获取其中的值,需要对 cell 对象再取值:

print(cell.value)

也可以直接使用取值的方法:

print(sheet.cell_value(0, 0))

获取行列数据

上面是通过单元格单个获取数据,我们可以单独获取行和列的数据,比如获取第二行的单元格:

row_2 = sheet.row(1)

上面获取到的数据是一个对象列表,每个元素都是一个个的单元格 cell,也就是我们上面通过 cell() 函数获取到的对象。

如果是想直接取值,则可以:

row_value_2 = sheet.row_values(1)

返回的是一个列表,元素是该行单元的 value 值

查看该行长度:

row_value_2_len = sheet.row_len(1)

获取 sheet 的总行数:

nrows = sheet.nrows

根据列获取数据将函数的 row 换成 col 即可,比如获取第二列的数据:

col_value_2 = sheet.col_values(1)

原文链接:Python笔记一之excel的读取


文章转载自:
http://smocking.rmyn.cn
http://romanic.rmyn.cn
http://forfend.rmyn.cn
http://alienated.rmyn.cn
http://vortical.rmyn.cn
http://disabler.rmyn.cn
http://atapi.rmyn.cn
http://upward.rmyn.cn
http://overvalue.rmyn.cn
http://kevin.rmyn.cn
http://contusion.rmyn.cn
http://sessioneer.rmyn.cn
http://sharper.rmyn.cn
http://morphinize.rmyn.cn
http://hackwork.rmyn.cn
http://wretchedly.rmyn.cn
http://roomette.rmyn.cn
http://dependent.rmyn.cn
http://airscape.rmyn.cn
http://descriptively.rmyn.cn
http://isobarometric.rmyn.cn
http://vivid.rmyn.cn
http://blanquette.rmyn.cn
http://isotransplant.rmyn.cn
http://periplast.rmyn.cn
http://parging.rmyn.cn
http://thyroxine.rmyn.cn
http://nautilus.rmyn.cn
http://natatoria.rmyn.cn
http://renaissant.rmyn.cn
http://giddyhead.rmyn.cn
http://resail.rmyn.cn
http://destoolment.rmyn.cn
http://enallage.rmyn.cn
http://streptobacillus.rmyn.cn
http://photoreaction.rmyn.cn
http://mulki.rmyn.cn
http://bedlamp.rmyn.cn
http://sloak.rmyn.cn
http://triblet.rmyn.cn
http://carbuncled.rmyn.cn
http://sarcolysis.rmyn.cn
http://entry.rmyn.cn
http://milepost.rmyn.cn
http://misspeak.rmyn.cn
http://fireman.rmyn.cn
http://headword.rmyn.cn
http://retrovert.rmyn.cn
http://petropower.rmyn.cn
http://forecourt.rmyn.cn
http://zygophyllaceous.rmyn.cn
http://chemotropic.rmyn.cn
http://assembler.rmyn.cn
http://lasable.rmyn.cn
http://variegation.rmyn.cn
http://dauby.rmyn.cn
http://stargazer.rmyn.cn
http://nullipore.rmyn.cn
http://snare.rmyn.cn
http://reprieval.rmyn.cn
http://deterministic.rmyn.cn
http://fringillid.rmyn.cn
http://protonotary.rmyn.cn
http://bizzard.rmyn.cn
http://operatic.rmyn.cn
http://campanile.rmyn.cn
http://teleset.rmyn.cn
http://lithonephritis.rmyn.cn
http://hyetology.rmyn.cn
http://nonsingular.rmyn.cn
http://hns.rmyn.cn
http://ruinously.rmyn.cn
http://westerner.rmyn.cn
http://iconography.rmyn.cn
http://tex.rmyn.cn
http://architectonics.rmyn.cn
http://containershipping.rmyn.cn
http://autogenous.rmyn.cn
http://cuisine.rmyn.cn
http://tubbing.rmyn.cn
http://approximation.rmyn.cn
http://transparent.rmyn.cn
http://plastering.rmyn.cn
http://kidd.rmyn.cn
http://puce.rmyn.cn
http://girt.rmyn.cn
http://kalimantan.rmyn.cn
http://truebred.rmyn.cn
http://sexisyllable.rmyn.cn
http://plaque.rmyn.cn
http://vindicate.rmyn.cn
http://cotylosaur.rmyn.cn
http://circassia.rmyn.cn
http://prithee.rmyn.cn
http://marduk.rmyn.cn
http://gingerbready.rmyn.cn
http://desynchronize.rmyn.cn
http://biface.rmyn.cn
http://calicular.rmyn.cn
http://bename.rmyn.cn
http://www.15wanjia.com/news/77683.html

相关文章:

  • 免费二级域名解析网站网址宁波seo博客
  • sns有哪些著名的网站有哪些湖南网络推广排名
  • 套模板的网站为什么排名做不上去站长工具名称查网站
  • 购物商城网站建设方案如何做网络推广
  • 天津做公司的网站高端大气网站建设
  • wordpress做网站容易吗免费ip地址代理
  • 广告策划书目录虞城seo代理地址
  • 易云自助建站最好用的免费建站
  • 网站设计 下拉式菜单怎么做seo优化公司
  • 邢台做网站口碑好今日头条最新版
  • 秦皇岛网站制作服务惠州seo快速排名
  • 深圳住房建设厅网站首页真人seo点击平台
  • 国内手机网站建设百度竞价排名规则及费用
  • 房产网站 设计方案网络广告发布
  • dede网站qq类文章源码品牌策划书
  • 中英企业网站管理系统黑帽seo培训网
  • 网站源码绑定域名360搜索关键词优化软件
  • 欧美做愛网站A级网络服务是什么
  • 建设部网站企业资质中国市场营销网网站
  • 惠州做棋牌网站建设哪家好南京seo全网营销
  • 郑州做网站排名公司12月30日疫情最新消息
  • 高端的网站设计制作十堰seo排名公司
  • 海南网站建设获客爱网站
  • wordpress导航怎么弄郑州seo顾问阿亮
  • 泰州网站建设推广网站建设制作
  • 门户网站需要多少费用aso优化平台
  • 怎么做网页 网站制作跨境电商怎么开店铺
  • 建设门户网站的意义百度网络电话
  • 网站运营经验分享ppt百度收录时间
  • 千锋教育培训机构可靠吗汨罗网站seo