接口返回数据:

print sql[0][10]

{"recv_name":"rdgztest_63126","send_name":"rdgztest_63126","recv_avatar":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJ2bWib0TF1ppuFHlbN2W1tcoy68o0MJGkOrSke6uBibHTnSI3a8DsEWW6icJ5Vu0OLN8wPWEfHRDe1w/132","send_avatar":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJ2bWib0TF1ppuFHlbN2W1tcoy68o0MJGkOrSke6uBibHTnSI3a8DsEWW6icJ5Vu0OLN8wPWEfHRDe1w/132","blessing_msg":"118默认祝福语"}

a = sql[0][10]

print type(a)
#输出为“Unicode”类型,转换为“str”类型
str1 = a.encode('utf-8')
print type(str1)
#将“str”转换为“dict”
dict = json.loads(str1)
print type(dict)
#“dict”取值
print dict["recv_name"]

python 接口测试字符类型转换的更多相关文章

  1. Python接口测试实战1(上)- 接口测试理论

    如有任何学习问题,可以添加作者微信:lockingfree 课程目录 Python接口测试实战1(上)- 接口测试理论 Python接口测试实战1(下)- 接口测试工具的使用 Python接口测试实战 ...

  2. 【已解决】python中文字符乱码(GB2312,GBK,GB18030相关的问题)

      http://againinput4.blog.163.com/blog/static/1727994912011111011432810/ [已解决]python中文字符乱码(GB2312,GB ...

  3. Python基础-字符编码与转码

    ***了解计算机的底层原理*** Python全栈开发之Python基础-字符编码与转码 需知: 1.在python2默认编码是ASCII, python3里默认是utf-8 2.unicode 分为 ...

  4. Python中文字符的理解:str()、repr()、print

    Python中文字符的理解:str().repr().print 字数1384 阅读4 评论0 喜欢0 都说Python人不把文字编码这块从头到尾.从古至今全研究通透的话是完全玩不转的.我终于深刻的理 ...

  5. Python的字符编码

    Python的字符编码 1. Python字符编码简介 1. 1  ASCII Python解释器在加载.py文件的代码时,会对内容进行编码,一般默认为ASCII码.ASCII(American St ...

  6. Python常用字符编码(转)

    Python常用字符编码   字符编码的常用种类介绍 第一种:ASCII码 ASCII(American Standard Code for Information Interchange,美国信息交 ...

  7. python生成字符画

    python生成字符画 这个idea来自于实验楼,非常适合练习PIL的像素处理,更重要的是非常有意思. 环境配置 依赖的第三方库就是PIL(Python Image Library),可以直接使用pi ...

  8. Python常见字符编码间的转换

    主要内容:     1.Unicode 和 UTF-8的爱恨纠葛     2.字符在硬盘上的存储     3.编码的转换     4.验证编码是否转换正确     5.Python bytes类型 前 ...

  9. python 3字符编码

    python 3字符编码 官方链接:http://legacy.python.org/dev/peps/pep-0263/ 在Python2中默认是ascii编码,Python3是utf-8编码 在p ...

随机推荐

  1. jQuery-AJAX-格式

    function loadInfo(){    var domainName=$("input[name='domain-name']").val(); //域名    var c ...

  2. python数据分析之:时间序列二

    将Timestamp转换为Period 通过使用to_period方法,可以将由时间戳索引的Series和DataFrame对象转换为以时期索引 rng=pd.date_range('1/1/2000 ...

  3. 教你管理SQL数据库系列(1-4)

    原文 教你管理 SQL Server 数据库(1)数据库的结构  http://bbs.51cto.com/thread-1084951-1.html教你管理 SQL Server 数据库(2)系统数 ...

  4. PAT 天梯赛 L2-014. 列车调度 【队列】

    题目链接 https://www.patest.cn/contests/gplt/L2-014 思路 其实 每条火车道 都可以视为一个队列 满足队列的性质 当已经存在的队列 中 的列车序号 都小于 当 ...

  5. Zookeeper启动Permission denied

    Zookeeper 查询状态,出现如下问题: JMX enabled by default Using config: /usr/zookeeper/zookeeper-/bin/../conf/zo ...

  6. nginx别名配置,状态配置,include优化

    一.nginx帮助参数 下面是关于/application/nginx/sbin/nginx 的参数帮助 [root@A conf]# /application/nginx/sbin/nginx -h ...

  7. vRA Customizing error

    toolsDeployPkg.log An error occurred while customizing VM vwbjvuqtest0751. For details reference the ...

  8. screen&tmux快捷键

    screen Key 快捷键 Action 动作 Notes 备注 Ctrl+a c new window 新窗口   Ctrl+a n next window 下一个窗口 I bind F12 to ...

  9. Web container==Servlet container

    Web container From Wikipedia, the free encyclopedia   (Redirected from Servlet container)     Web co ...

  10. codevs1279 Guard 的无聊

    题目描述 Description 在那楼梯那边数实里面,有一只 guard,他活泼又聪明,他卖萌又霸气.他每天刷题虐 场 D 人考上了 PKU,如果无聊就去数一数质数~~ 有一天 guard 在纸上写 ...