python自动化测试,读取excal数据报"'str' object has no attribute 'items'"问题解决
通过python进行自动化测试,为了方便,对代码和数据进行了分离,此处把测试数据放到了excal表格中。requests.post请求时报"'str' object has no attribute 'items'",
excal表格里的测试数据是json字符串的数据,经过问题解决后的分析得出,获取字符串数据之后直接放到requests里面进行请求会出现无法解析的情况。因此在原获取excal表格数据的代码data= (result_need(0,1,0))里加上data= eval((result_need(0,1,0))),这样利用eval函数将字符串转变为字典,再进行post的请求就成功了。
这个问题能够解决是我参照我去年写的另一篇博客的其中一段代码获得的灵感:“result_json=eval(result.text)[父元素1][子元素2] #利用eval函数将字符串转变为字典,在字典中获取想要的value值” 。博客地址:http://www.cnblogs.com/yinze/p/8166601.html
python自动化测试,读取excal数据报"'str' object has no attribute 'items'"问题解决的更多相关文章
- Python PyInstaller 打包报错:AttributeError: 'str' object has no attribute 'items'
pyinstaller打包时报错:AttributeError: 'str' object has no attribute 'items' 网上查询,可能是setuptools比较老: 更新一下 p ...
- pyinstaller打包报错:AttributeError: 'str' object has no attribute 'items'
导致原因和python多数奇奇怪怪的问题一样,依赖包的版本问题. 解决办法: 对setuptools这个包进行升级,链接在这里 https://pypi.org/project/setuptools/ ...
- Django2.2报错 AttributeError: 'str' object has no attribute 'decode'
准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: AttributeError: 'str' object has ...
- Django项目与mysql交互进行数据迁移时报错:AttributeError: 'str' object has no attribute 'decode'
问题描述 Django项目启动,当我们执行命令 python manage.py makemigrations 出现如下错误: File , in last_executed_query query ...
- 解决编码问题:AttributeError: 'str' object has no attribute 'decode'
1. 问题发现: 出现:读取文件,对其进行解码,出现错误,AttributeError: 'str' object has no attribute 'decode' 解释:属性错误,str对象不包含 ...
- Django 运行报异常:AttributeError: 'str' object has no attribute 'get'
Technorati Tags: Python,Django,Web 在使用django.contrib.auth用户机制进行用户的验证.登录.注销操作时,遇到这个异常. 首先是写了一个登录的视图,要 ...
- 【Python-遇到的Error】AttributeError: 'str' object has no attribute 'input_text'
学习类的实例化的时候遇到了AttributeError: 'str' object has no attribute 'input_text', 以下是报错的代码及修改正确的代码. class shu ...
- python2 'str' object has no attribute 'decode'
'.decode('hex') 上述代码,报错: 'str' object has no attribute 'decode' 查找原因: https://stackoverflow.com/ques ...
- python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'
1.Python3.x和Python2.X版本有一些区别,我遇到了两个问题如下: a.第一个报:mysqlclient 1.3版本不对: 解决办法:注释掉这行即可: b.第二个报:字符集的问题: 报错 ...
随机推荐
- gcc g++ 安装与配置 入门详解 - 精简归纳
gcc g++ 安装与配置 入门详解 - 精简归纳 JERRY_Z. ~ 2020 / 9 / 24 转载请注明出处!️ 目录 gcc g++ 安装与配置 入门详解 - 精简归纳 一.下载MinGW ...
- PHP代码审计01之in_array()函数缺陷
前言 从今天起,结合红日安全写的文章,开始学习代码审计,题目均来自PHP SECURITY CALENDAR 2017,讲完这个题目,会再用一道有相同问题的CTF题来进行巩固.下面开始分析. 漏洞分析 ...
- 使用implicitly demo
泛型: Context Bounds // //定义一个隐式值, 这个值不能少, 要不找不到比较的对象 implicit val personCompartor = new Ordering[Per ...
- Spring学习(七)--Spring的AOP
1.实现AOP的方式:通过proxy代理对象.拦截器字码翻译等. 2.AOP体系分层图,从高到低,从使用到实现: 基础:待增强或者目标对象 切面:对基础的增强应用 配置:把基础和切面结合起来,完成切面 ...
- Centos-显示文件类型-file
file 长度为0的文件则显示为空位文件,对于软链接文件则显示链接的真实文件路径,默认输出会有文件名 相关选项 -b 只显示文件类型结果 -L 显示软链接指向文件的类型 -z 显示压缩文件信息 -i ...
- 073 01 Android 零基础入门 01 Java基础语法 09 综合案例-数组移位 05 综合案例-数组移位-主方法功能1和2的实现
073 01 Android 零基础入门 01 Java基础语法 09 综合案例-数组移位 05 综合案例-数组移位-主方法功能1和2的实现 本文知识点:综合案例-数组移位-主方法功能1和2的实现 说 ...
- 总线SPI的Arduino库函数
来源参考:https://www.cnblogs.com/MyAutomation/p/9348480.html 总线SPI的Arduino库函数 SPI基本知识 SPI:高速同步串行口.是一种标准的 ...
- 连Python产生器(Generator)的原理都解释不了,还敢说Python用了5年?
最近有很多学Python同学问我,Python Generator到底是什么东西,如何理解和使用.Ok,现在就用这篇文章对Python Generator做一个敲骨沥髓的深入解析. 为了更好地 ...
- Go strconv包
strconv包 该包主要实现基本数据类型与其字符串表示的转换. 常用函数为Atoi().Itia().parse系列.format系列.append系列. 更多函数请查看官方文档. string与i ...
- mycat相关配置文件和参数解析
#vi /usr/local/mycat/conf/schema.xml<!--######################################################### ...