通过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. python自动保存百度网盘资源

    觉得有帮助的别忘了关注一下知识图谱与大数据公众号,完整代码移步从今天开始种树 开始 在上一文中,我们保存了百度云盘的地址和提取码,但是这种分享链接很容易被屏蔽,最好的做法就是保存资源到自己的网盘,不过 ...

  2. 微信小程序-简介

    微信小程序定位 1. 不需要下载安装即可使用 2. 用户用完即走,不用关系是否安装太多应用 3. 应用无处不在,随时可用 # 不要安装可使用是个伪命题,因为小程序的安装包小于1M,下载安装到使用的过程 ...

  3. 我们解决了如何将视频转换为HEVC / H.265和AVC / H.264

    LEADTOOLS Recognition Imaging SDK是精选的LEADTOOLS SDK功能集,旨在在企业级文档自动化解决方案中构建端到端文档成像应用程序,这些解决方案需要OCR,MICR ...

  4. 模型集成model ensemble

    A prediction model that is composed of a set of models is called a model ensemble. Baggging 和Boostin ...

  5. 硬核测试:Pulsar 与 Kafka 在金融场景下的性能分析

    背景 Apache Pulsar 是下一代分布式消息流平台,采用计算存储分层架构,具备多租户.高一致.高性能.百万 topic.数据平滑迁移等诸多优势.越来越多的企业正在使用 Pulsar 或者尝试将 ...

  6. aarch64架构移动设备挂载移动硬盘

    添加yum源 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 安装ntfs yum inst ...

  7. TCHAR数据类型介绍

    转载:https://blog.csdn.net/mousebaby808/article/details/5259944 并不是所有的Windows操作系统都支持UNICODE编码的API(例如早期 ...

  8. apt-get 安装软件时出现:“文件尺寸不符” 问题

    报错信息 命中:1 http://packages.deepin.com/deepin panda InRelease 命中:2 http://linux.teamviewer.com/deb sta ...

  9. 三、Requests库的使用

    requests 的底层实现其实就是 urllib3 Requests 唯一的一个非转基因的 Python HTTP 库,人类可以安全享用. 学过关于urllib库的使用,你会发现它是很不方便的.而R ...

  10. 如何选择JVM垃圾回收器?

    明确垃圾回收器组合 -XX:+UseSerialGC 年轻代和老年代都用串行收集器 -XX:+UseParNewGC 年轻代使用ParNew,老年代使用 Serial Old -XX:+UsePara ...