python自动化测试学习笔记-6excel操作xlwt、xlrd、xlutils模块
python中通过xlwt、xlrd和xlutils操作xls
- xlwt模块用于在内存中生成一个xls/xlsx对象,增加表格数据,并把内存中的xls对象保存为本地磁盘xls文件;
- xlrd模块用于把本地xls文件加载到内存中,可以读取xls文件的表格数据,查询xls文件的相关信息;
- xlwt可以生成xls文件,xlrd可以读取已经存在的xls文件,但是如果要修改本地已经存在的xls文件,就需要用到xlutils模块。
- xlutils模块是xlrd和xlwt之间的桥梁,可以使用xlutils模块中的copy模块,拷贝一份通过xlrd读取到内存中的xls对象,就可以在拷贝对象上像xlwt中那样修改xls表格的内容,并保存到本地。
要使用这些模块首先要安装导入:
pip install xlrd
pip install xlwt
pip install xluntils
安装好后进行导入
import xlrd
import xlwt
from xlutils.copy import copy
#创建一个excel
book=xlwt.Workbook()
#添加一个sheet
sheet=book.add_sheet('sheet1')
#向sheet中添加数据,行、列、value值
sheet.write(0,0,'id')
sheet.write(0,1,'name')
sheet.write(0,2,'age')
sheet.write(0,3,'sex')
#保存xls,微软的office不能以xlsx为结尾,wps随意
book.save('peitest.xls')
执行后生成了一个excel文件,查看内容
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAToAAACaCAIAAAC2SxNRAAAPa0lEQVR4nO2dXU8b2R2H56v4Yr8E14hIkXYvVlVabdWqalpolN7s0gDZNrBUbQQJjRwpTRc322wS1NDF65GBNRCwIQEb5BAgiWMCJmA7vHshIslGWmml6cVg+3g8ZmzPOfOfIb9H52I8mPHPx+fxOXM8L1IoFLp3715/f38sFnvw4IEsy67GOqWQSCSi6FFbW6u7XGrNe0Kp6tJlYGBgYGCA+8Z3d3efPHmyvr5e/Kcff/wxkUi8evWq/Bctk8XFxYcPH87NzR0cHHDfuMr58+cXFhba2tqGhoYURan6XbDVWNHnlePoBl9bWyui/UtV61qbRbPMPhQU2uZU9/HbYeMm+emnnzY3Nzc2NsS9xJ07dzweTyAQMLkdM7oe0byLpTCZU4O0v7+/s7OTSqWq6F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ezsO8T8C6GoW6Fod6gl0V65cUfddr1y5ghPoDIGuZoGuwDKgq1k0Bxs5t1BXJDAGupqFXDPo+v4AXQFwDNAVAMcAXQFwDPq6oqCg2LBAVxQUxxToioLimAJdUVAcUxym6wdNJzsHb8TWE7H1ROfgjQ+aTpJHQkGxrFSs660p/1pmPfdwLbN+6tpnmucoisI+fzQW4RX3cuDmzsFerlwO3HQ11rFr1EJerSgoIko1vetaZv3WlD+3fOraZ4qitMvX1TUaP9mHa5n13NOqK0tba6yWS1trLuiK8t6UCnSdS8Y1x4WrPa1q4P4PB+rTcn1vu3ydfTIredUFuqK8z8XUvqvG3tFY5NaUX7U3J6fau84l41yGxJrB8D+Gvi5+DnRFOa6lMl01vaWrsW7/h4PRWIQd7qp/nUvG9384KD5Ray4ZNxP3g6aT7pHb8Y0X8Y0X7pHbulNN0BXluJaKdVUXTl37TFdX9k+5khsniyi50S+7QF6tKCgiyv8BhxfZJSc6BPsAAAAASUVORK5CYII=" alt="" />
但是像这样一个单元格一个单元格的插入又很浪费时间,我们可以用循环来实现,如下:
##############################
#利用循环写数据
#创建一个excel
book=xlwt.Workbook()
#添加一个sheet
sheet=book.add_sheet('sheet2')
row=
col=
list=[
['id','name','age','sex'],
['01','wang','13','女'],
['02','li','23','女'],
['03','hang','34','男'],
['04','wu','16','女'],
['05','ma','22','女']
]
#循环行
for r in range(6):
#循环列
for c in range(4):
#根据行和列找到要赋值的value
sheet.write(r,c,list[r][c])
c+=
r+=
#保存excel
book.save('peitest.xls')
执行查看结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYEAAADvCAIAAACbsv/tAAAbbklEQVR4nO2d3W8UR7rG51/xRfYfOFqd1ShHygVxpKxyt8rFXu0q0ni52Yt4E1CUQKyNWBsIDAlfdrKJ+XAYsPHIBNp4/XHIwhjWITgkg4kxwfaAwcEBxEdy23vRM93V3dXTVeOuequb56dXqJlp9zxdU/VMVXXX27mxfx07VjrQ1tlu+5menraBMEqLC99FIrD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BOL5jNzM5dHxiePkOhAIxPMZudmrE/++UCbXgUAgns/IXbv+1X++tsh1IBCI5zNy3343Wbn45fjE8ZFT/ceOHzh0eM+n//yw75MdB3p7RGLfgW1uCP7Jx3v//vHev+/d98HH+z5gtwX//EBvz74D/3CCv8PB7n37t3308Qe7dndt3/Hu+11/+9tbG3/3u//55NMDO3a+78Ynn+x/+eWX+vv7P2uV/v7+QqHAfevDP/5hx0u/3d3+Yu/777Kv977/7u72F3e89Ntdf/xD1GGjjrkejgFgKrkf5s9/+93kxf+c/v+vTlqjR8sjn50Y7C2dOHh0YK9IHD7ykRuCf/J5/67P+3f1H97df3g3uy345+yHct89MrD30JGPPuvf3ffJzn37/7Fj55YtW9988f/+t3T8yP6D2/cf3H7g4PYDB7eXSod///v2kydPDkUz+PGffpPL5XK5l98ZfOfl3G/+9DH77smTJ//617/y//DE8c/+8ueB7dvCbw1s3/b5X/48ePx41IdGHXM9nAHAVP4LPB+SRkE90VAAAAAASUVORK5CYII=" alt="" />
上述方法是已知数据的行和列来循环的,如果行和列太多的时候就不方便了,我们可以通过循环list来添加数据,如下:
#创建一个excel
book=xlwt.Workbook()
#添加一个sheet
sheet=book.add_sheet('sheet3')
list=[
['id','name','age','sex'],
['01','wang','13','女'],
['02','li','23','女'],
['03','hang','34','男'],
['04','wu','16','女'],
['05','ma','22','女']
] r=0
for stu in list:
c=0
for s in stu:
sheet.write(r,c,s)
c+=1
r+=1
book.save('peitest.xls')
执行查看结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUMAAADSCAIAAABfHDUCAAAYT0lEQVR4nO2dXW/bRrqA9Vf8N3QdeK/6Kw4gI9dGkaBAk81NYRdBoCxQnI2vdrdxYyCBBbepmrRx25xUsmNblk8i2/GXLIkipcRxgnzAt9wLiuSQHJIzEmfmJfk+4IXCMMzL0TyaGXLmZUEfNPVBc/D6/6M36zDrSGO4ow+amr592t3YP/i/ja1fHv96797S/07NTpsIgqigwGzytrWhyQgCEDQZQbI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kxv2kR6Td/fFmlwngH9aLsboXduCecfJtsntJ5fdPrN9PHVnlMmRf6XK5K+++urs7Mz6fCUE62+tDraEkKBhmcyQM8RwTG72jW3S5PUNbJPHgfuOl9s40002X85TDKTuzK7Jg8Hg66+/lhASNNKxgiLX4+SX87a0jsAhJnsfID25G7HT1xWvf+mqC/Ep1Pz8/NHRkW8n9q5J0mHyRa7vXQfnbISZPGq3/feuqTudW1zWOZ3b4/4xOQiTHzx4wH7Ha3l5WUJI0EiNydkDZ2uyg0+hYknHU6hMgiZz8eDBA5aZIflskC/QZIWgyVxYszUXFhacW18kZ2dnd+7cwdmaaLIC0OQxWF1dvXHjRqVS2dvbGw6Hw+Fwb2+vUqncuHEDV1CgyWpAk8fDWtV469Yta5x869YtXNV4gSYrBE1GEgRNVoZv6lV6N9UFiVxcoMkKUW4gmpwl0GQEyQJhb131b9aSKc2grKBY33j4y+PFxXui5l0jCBILs8nha6HQZARRDqfJcW0ybrjhpmRLOLcmbrjhpmRDk3HDLQvbfwEs2Zs7gXshTAAAAABJRU5ErkJggg==" alt="" />
读取excel的数据是通过xlrd模块来实现的,如下:
###############################################################################
#读取excel数据
book=xlrd.open_workbook('peitest.xls')
#获取sheet,通过index
sheet=book.sheet_by_index(0)
#获取sheet通过sheet名称
#sheet=book.sheet_by_name('sheet3')
value=sheet.cell(0,0).value
value1=sheet.cell(0,1).value
value2=sheet.cell(0,2).value
value3=sheet.cell(0,3).value print(value)
print(value1)
print(value2)
print(value3)
执行查看结果:
id
name
age
sex
同样的,如果我们要读取出excel所有的数据,也可以用循环来实现:
#####################################33
#循环来实现读取excel数据
#打开excel
book=xlrd.open_workbook('peitest.xls')
#获取sheet
sheet=book.sheet_by_name('sheet3')
#获取sheet中的行数
row=sheet.nrows
#获取sheet中的列数
col=sheet.ncols
#获取每一行的数据
for i in sheet.get_rows():
print(i)
#获取某一行的数据,通过循环获取出所有数据
for r in range(row):
print(sheet.row_values(r))
#获取某一列的数据,通过循环获取出所有数据
for c in range(col):
print(sheet.col_values(c))
执行查看结果:
[text:'id', text:'name', text:'age', text:'sex']
[text:'01', text:'wang', text:'13', text:'女']
[text:'02', text:'li', text:'23', text:'女']
[text:'03', text:'hang', text:'34', text:'男']
[text:'04', text:'wu', text:'16', text:'女']
[text:'05', text:'ma', text:'22', text:'女']
['id', 'name', 'age', 'sex']
['01', 'wang', '13', '女']
['02', 'li', '23', '女']
['03', 'hang', '34', '男']
['04', 'wu', '16', '女']
['05', 'ma', '22', '女']
['id', '01', '02', '03', '04', '05']
['name', 'wang', 'li', 'hang', 'wu', 'ma']
['age', '13', '23', '34', '16', '22']
['sex', '女', '女', '男', '女', '女']
我们看到上面第一种方法,每一个数据都带一个text,不方便进行后续操作,所以一般用第二种方式来实现。
修改文件
#######################################
import xlrd
import xlwt
from xlutils.copy import copy
#修改excel文件
#打开文件
book=xlrd.open_workbook('peitest.xls')
#复制一份文件用于修改
book2=copy(book)
#获取要修改的sheet
sheet=book2.get_sheet(0)
#修改指定的行和列
sheet.write(0,0,'序号')
#保存为新的excel
book2.save('peitest1.xls')
执行查看结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADlCAIAAADyRTZdAAAc/klEQVR4nO2dXW/bxraG9Vd80T+h68IFCvS2f6CAjNzWaBMUaHpyU9jdOYW6kd3TGBto0500BhJYcOIqcR0n6bElJ5I/mpRR6tixZUqK3bhJkH7d8lxQJIfkUCQ1M1xDnffBIJBpRX45H6/WDDmLhe6zDbs8O/qpd7jV6W3uHzQeb/9vY/3G4g+XL8/+z9jkuOWnXq9bIDFKqwttIQW2GlGlOlOAYakGhqU/MKy8AMNSDgxLf2BYeWFIwwKpUNd+1Gc2OqBKc8EwhgUAACTAsAAAuQGGBQDIDYXus00YFgAgF9iGtQnDAgDoj2tYmzAsAIDmwLAAALmhYHabZrdpdhud3rrZbbbNxu5e3WjdWbt/vXrz4qXvzsGwAACaAMMCAOQG17CaMCwAgOZkvYb14MGDgzzz4MEDibWRPa9evaKWI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OcAFhiUZGNYQLC8vnzlzplKptFqto6Ojo6OjVqtVqVTOnDmDzc+AxcmH1W10eutmt9k2G7t7daN1Z+3+9erNi5e+OwfDSgUMazjs9DKff/65vYb1+eefI70MCAPDkgwMCwB1uIbVhGFJIXADen4LdUUCwAFrWJIhNxoYFhhhYFgAgNwAwwIA5AYYFgAgNyQyLBQUFBQdCgwLBQUlNwWGhYKCkpsCw0JBQclNybdhvfHh29ML/za6O0Z3Z3rh3298+Da5JBQUFHVF1LAurM7vH3fdH/ePu++eez/wHsuy2PcvGXVZ6v9R/frX1y/c8o/q12OT4+wRu5DXMgoKipQiIcLaP+5eWJ13X7977n3Lss5UvrSPBByK/XH/uOu+bbiyfbjPGtP24f4YDAsFZXTL8Ia12W4Fdsza0ZbtQS//em2/zY2/zlS+ZN/M2tzQBYaFgvL/qshcwwr415JRv7A6b/uXa092hLXZbkmZGAamhP9945vwe2BYKCgjU4QMKxAxjU2Ov/zr9ZJRZyd99m83262Xf70OpzHZbLdE1L/x4dvlxW9bvaet3tPy4rfcRXcYFgrKyJRCp7fe6a2bvWant2F217npZaKKu5r+7rn3uYbF/sot7mxRRXHngOwL8lpGQUGRUgKGxc+HFVUCEZbtTQHDYu1pyahLDK/ssnXwePAbYFgoKCNTbMNqmr1BCfyiim1GL/96bVuPbVWsYQUcyl6Yt391pvKlFMMKx1OIsFBQRrUIXSW8sDr/7rn3X/712v7XfuEaVmDqt9luBS4sSjQskTegoKDkpUi4Smgbk+1HY06cxS5d2T51YXXe9jj7ICIsFBSUtOX/AITl04XPUJd8AAAAAElFTkSuQmCC" alt="" />
python自动化测试学习笔记-6excel操作xlwt、xlrd、xlutils模块的更多相关文章
- 操作excel--xlwt/xlrd/xlutils模块
一.写Excel (导入xlwt模块)需求:只要你传入一个表名,就能把所有的数据导入出来写入excel,字段名是excel的表头分析: 1.要动态获取到表的字段 cur.description能获取到 ...
- python自动化测试学习笔记-10YAML
之前学习的编写测试用例的方法,都是从excel中编写接口的测试用例,然后通过读取excel文件进行接口自动化测试,这种方式我们叫做数据驱动的方式,由于excel操作起来不灵活,无法实现关联关系的接口测 ...
- python自动化测试学习笔记-9测试框架
学习了这么久的python,我们已经可以自己搭建一个简单的测试和框架了,先从简单的开始,有时我们编写接口的测试用例会用excel进行编写,以下面的接口测试用例模板为例,进行编写:
- python自动化测试学习笔记-1
一.什么是自动化 自动化测试是把以人为驱动的测试行为转化为机器执行的一种过程.直白的就是为了节省人力.时间或硬件资源,提高测试效率,便引入了通过软件或程序自动化执行测试用例进行测试: 二.python ...
- Python Excel文件的读写操作(xlwt xlrd xlsxwriter)
转:https://www.cnblogs.com/ultimateWorld/p/8309197.html Python语法简洁清晰,作为工作中常用的开发语言还是很强大的(废话). python关于 ...
- python自动化测试学习笔记-6urllib模块&request模块
python3的urllib 模块提供了获取页面的功能. urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capat ...
- python自动化测试学习笔记-5常用模块
上一次学习了os模块,sys模块,json模块,random模块,string模块,time模块,hashlib模块,今天继续学习以下的常用模块: 1.datetime模块 2.pymysql模块(3 ...
- python自动化测试学习笔记-4常用模块
常用模块 1.os 2.sys 3.random 4.string 5.time 6.hashlib 一.os模块 os模块主要用来操作文件.目录,与操作系统无关.要使用os模块首先要导入OS模块,用 ...
- python自动化测试学习笔记-4内置函数,处理json
函数.全局变量 写代码时注意的几点事项: 1.一般写代码的时候尽量少用或不用全局变量,首先全局变量不安全,大家协作的情况下,代码公用容易被篡改,其次全局变量会一直占用系统内容. 2.函数里如果有多个r ...
随机推荐
- 【转】Java读写文件大全
使用Java操作文本文件的方法详解 最初java是不支持对文本文件的处理的,为了弥补这个缺憾而引入了Reader和Writer两个类,这两个类都是抽象类,Writer中 write(ch ...
- hdu 3622 二分+2-sat
/* 二分+2-sat 题意:在一个二维平面上给你n个炸弹,和2*n个位置,每一行的两个位置只能有一个放炸弹 现在炸弹爆炸有一个半径,当炸弹爆炸时两个炸弹的半径化成的圆不能相交,求最大半径 二分半径, ...
- ehcache、memcache、redis三大缓存比较
最近项目组有用到这三个缓存,去各自的官方看了下,觉得还真的各有千秋!今天特意归纳下各个缓存的优缺点,仅供参考! Ehcache 在Java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS ...
- Avito Code Challenge 2018 C
C. Useful Decomposition time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 快速幂取模模板 && 51nod 1013 3的幂的和
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #in ...
- 百度语音识别API初探
近期想做个东西把大段对话转成文字.用语音输入法太慢,所以想到看有没有现成的API,网上一搜,基本就是百度和讯飞. 这里先看百度的 笔者使用的是Java版本号的 下载地址:http://bos.nj.b ...
- linux网络结构体
一 链路层: (1)局域网(以太网ethernet): *struct eth_header:以太网头部. (ethernet/eth.c) *struct net_device:每一个网络设备都用这 ...
- CCNP路由实验之八 路由重公布
CCNP路由实验之八 路由重公布 在前面几个实验,已经学习了静态路由和动态路由.如今,我们要掌握怎样使它们在一个网络中融合,即路由重公布. 使用出站口作为静态路由 0 使用下一跳地址作为静态路由 ...
- Mali GPU OpenGL ES 应用性能优化--基本方法
1. 经常使用优化工具 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTXlBcnJvdw==/font/5a6L5L2T/fontsize/400/fil ...
- C#高级编程五十四天----Lookup类和有序字典
Lookup类 Dictionary<Tkey,TValue>仅仅为每一个键支持一个值.新类Lookup<Tkey,TValue>是.NET3.5中新增的,它类似与Dictio ...