通过openpyxl从excel中获取每一行数据时获取到“None”问题
问题截图:
当excel中存在
打印结果:每行出现两个None
###### (<Cell 'Sheet3'.A1>, <Cell 'Sheet3'.B1>, <Cell 'Sheet3'.C1>, <Cell 'Sheet3'.D1>, <Cell 'Sheet3'.E1>, <Cell 'Sheet3'.F1>, <Cell 'Sheet3'.G1>, <Cell 'Sheet3'.H1>, <Cell 'Sheet3'.I1>)
功能点
用例编号
用例说明
测试类型
前提条件
测试步骤
预期结果
None
None
###### (<Cell 'Sheet3'.A2>, <Cell 'Sheet3'.B2>, <Cell 'Sheet3'.C2>, <Cell 'Sheet3'.D2>, <Cell 'Sheet3'.E2>, <Cell 'Sheet3'.F2>, <Cell 'Sheet3'.G2>, <Cell 'Sheet3'.H2>, <Cell 'Sheet3'.I2>)
登陆功能(正常登陆)
DL001
测试正常登陆功能是否正确
正常类测试
已知正确url = "https://www.ketangpai.com/UserApi/login"
date = {"email": "18334680659", "password": "123456"}
self.assertEqual('success',info1[0],'登陆接口出错')
None
None
###### (<Cell 'Sheet3'.A3>, <Cell 'Sheet3'.B3>, <Cell 'Sheet3'.C3>, <Cell 'Sheet3'.D3>, <Cell 'Sheet3'.E3>, <Cell 'Sheet3'.F3>, <Cell 'Sheet3'.G3>, <Cell 'Sheet3'.H3>, <Cell 'Sheet3'.I3>)
登陆功能(账号正确+密码错误)
DL002
测试账号正确+密码错误登陆提示是否正确
异常类测试
已知正确url = "https://www.ketangpai.com/UserApi/login"
date = {"email": "18334680659", "password": "123457"}
self.assertEqual('密码错误',info1[0],'登陆接口出错')
None
None
###### (<Cell 'Sheet3'.A4>, <Cell 'Sheet3'.B4>, <Cell 'Sheet3'.C4>, <Cell 'Sheet3'.D4>, <Cell 'Sheet3'.E4>, <Cell 'Sheet3'.F4>, <Cell 'Sheet3'.G4>, <Cell 'Sheet3'.H4>, <Cell 'Sheet3'.I4>)
登陆功能(账号错误+密码正确)
DL003
测试账号错误+密码正确登陆提示是否正确
异常类测试
已知正确url = "https://www.ketangpai.com/UserApi/login"
date = {"email": "18334680658", "password": "123456"}
self.assertEqual('用户不存在',info1[0],'登陆接口出错')
None
None
###### (<Cell 'Sheet3'.A5>, <Cell 'Sheet3'.B5>, <Cell 'Sheet3'.C5>, <Cell 'Sheet3'.D5>, <Cell 'Sheet3'.E5>, <Cell 'Sheet3'.F5>, <Cell 'Sheet3'.G5>, <Cell 'Sheet3'.H5>, <Cell 'Sheet3'.I5>)
登陆功能(账号正确+密码为空)
DL004
测试账号错误+密码为空登陆提示是否正确
异常类测试
已知正确url = "https://www.ketangpai.com/UserApi/login"
date = {"email": "18334680659", "password": ""}
self.assertEqual('密码不能为空',info1[0],'登陆接口出错')
None
None
解决方法:
将还加边框的空单元格所对应的的列删除或者将需要打印的内容从新copy到新的excel中,再次同openpyxl获取每行数据时,就正确了。