一、导入库失败
使用HttpLibrary.HTTP:(这个库在python3中引用不知道为啥要报错,在python2中就正常)
使用这个库刚开始安装后导入失败(一直显示红色),查看日志发现是需要装几个依赖库webtest、jsonpointer、jsonpatch,在https://pypi.org/搜索安装就行,日志中有相关提示缺少什么
二、中文乱码
HttpLibrary.HTTP库不支持中文返回的数据中文显示乱码,在该库文件中__init__.py中修改get_respons_body函数,如下图加.decode()
此时有可能报UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe7 in position 0: ordinal not in range(128)错误,处理方法:
(因为python3中默认就是utf8,不要添加下面的东西,添加了使用命令会有警告)
1.此时再在上面文件中加入下面的代码就ok
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
2.在Python安装目录下的Lib/site-packages中,新建sitecustomize.py文件内容如下:
import sys
sys.setdefaultencoding('utf-8') #set default encoding to utf-8