通过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'"问题解决的更多相关文章

  1. Python PyInstaller 打包报错:AttributeError: 'str' object has no attribute 'items'

    pyinstaller打包时报错:AttributeError: 'str' object has no attribute 'items' 网上查询,可能是setuptools比较老: 更新一下 p ...

  2. pyinstaller打包报错:AttributeError: 'str' object has no attribute 'items'

    导致原因和python多数奇奇怪怪的问题一样,依赖包的版本问题. 解决办法: 对setuptools这个包进行升级,链接在这里 https://pypi.org/project/setuptools/ ...

  3. Django2.2报错 AttributeError: 'str' object has no attribute 'decode'

    准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: AttributeError: 'str' object has ...

  4. Django项目与mysql交互进行数据迁移时报错:AttributeError: 'str' object has no attribute 'decode'

    问题描述 Django项目启动,当我们执行命令 python manage.py makemigrations 出现如下错误: File , in last_executed_query query ...

  5. 解决编码问题:AttributeError: 'str' object has no attribute 'decode'

    1. 问题发现: 出现:读取文件,对其进行解码,出现错误,AttributeError: 'str' object has no attribute 'decode' 解释:属性错误,str对象不包含 ...

  6. Django 运行报异常:AttributeError: 'str' object has no attribute 'get'

    Technorati Tags: Python,Django,Web 在使用django.contrib.auth用户机制进行用户的验证.登录.注销操作时,遇到这个异常. 首先是写了一个登录的视图,要 ...

  7. 【Python-遇到的Error】AttributeError: 'str' object has no attribute 'input_text'

    学习类的实例化的时候遇到了AttributeError: 'str' object has no attribute 'input_text', 以下是报错的代码及修改正确的代码. class shu ...

  8. python2 'str' object has no attribute 'decode'

    '.decode('hex') 上述代码,报错: 'str' object has no attribute 'decode' 查找原因: https://stackoverflow.com/ques ...

  9. python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'

    1.Python3.x和Python2.X版本有一些区别,我遇到了两个问题如下: a.第一个报:mysqlclient 1.3版本不对: 解决办法:注释掉这行即可: b.第二个报:字符集的问题: 报错 ...

随机推荐

  1. DVWA从注入到GETSHELL

    好好过你的生活,不要老是忙着告诉别人你在干嘛. 最近在复习学过的东西,自己就重新搭了个dvwa来学习新思路,写一些简单的脚本来练习写代码的能力. 众所周知SQL注入的危害是相当大的,对于每个老司机来说 ...

  2. Ubuntu18.04安装常用软件指南

    安装中文版火狐浏览器 第一步:先卸载:sudo apt-get remove firefox第二步:安装:sudo apt-get install firefox第三步:设置成中文:sudo apt- ...

  3. 有关图的连通性的Tarjan算法

    割点与桥 在一个无向连通图中,若将某个点及其相连的边删除后,图就不连通了,则这样的点被称为割点. 在一个无向连通图中,若将某条边删除后,图就不连通了,则这样的边被称为割边,即桥. 在一张图中求出割点或 ...

  4. springboot集成swagger文档

    //此处省略springboot创建过程 1.引入swagger相关依赖(2个依赖必须版本相同) <dependency> <groupId>io.springfox</ ...

  5. Go 基本类型

    整形 标准整形 标准整形是按长度进行分类的,其中uint8为byte型,int16为C语言中的short型,int64为C语言中的long类型. 类型 描述 uint8 无符号 8位整型 (0 到 2 ...

  6. Android捕捉错误try catch 的简单使用

    基本语法 try{ //可能发生错误的程式码 }catch(具体错误 e){ //具体错误有就写,没有就不写,有多个,就写多个catch e.printStackTrace(); //在命令行打印错误 ...

  7. 利用mindmaster思维导图学好Python

  8. 【Hadoop】伪分布式安装

    创建hadoop用户 创建用户命令: sudo useradd -m hadoop -s /bin/bash 创建好后需要更改hadoop用户的密码,命令如下: sudo passwd hadoop ...

  9. Matlab中界面和注释---中英文切换问题

    有参考网页后实践的心得: Matlab中界面和注释---中英文切换问题 网上有大把的方法,并不是一一有效,这里介绍一种比较简单的方法我自己的电脑挺好用的,大家的电脑matlab需要你们自己实验了. 1 ...

  10. Noip 2013 真题练习

    Day1 T1 转圈游戏 Link 一句话题意: 让你求 \({x + m \times 10^k} \bmod n\) 的结果. 直接套上快速幂的板子. code #include<iostr ...