Python pass 语句 https://www.runoob.com/python/python-pass-statement.html
Python dict() 函数 https://www.runoob.com/python/python-func-dict.html
Python3 join()方法 https://www.runoob.com/python3/python3-string-join.html
Python3 split()方法 https://www.runoob.com/python3/python3-string-split.html
Python strip()方法 https://www.runoob.com/python/att-string-strip.html
Python round() 函数 https://www.runoob.com/python/func-number-round.html
Python str() 函数 https://www.runoob.com/python/python-func-str.html
Python enumerate() 函数 https://www.runoob.com/python/python-func-enumerate.html
Python中“if __name__=='__main__':”理解与总结 https://www.cnblogs.com/chenhuabin/p/10118199.html
Python3 基本数据类型 https://www.runoob.com/python3/python3-data-type.html
Python object类中的特殊方法代码讲解 https://www.jb51.net/article/182040.htm
Python之Class&Object用法详解 https://www.jb51.net/article/177209.htm
python with as的用法 https://www.jianshu.com/p/1a02a5b63c88
Python异常和错误 https://blog.youkuaiyun.com/u014465934/article/details/81071049
一、概念理解
1、json.dumps()和json.loads()是json格式处理函数(可以这么理解,json是字符串)
(1)json.dumps()函数是将一个Python数据类型列表进行json格式的编码(可以这么理解,json.dumps()函数是将字典转化为字符串)
(2)json.loads()函数是将json格式数据转换为字典(可以这么理解,json.loads()函数是将字符串转化为字典)2、json.dump()和json.load()主要用来读写json文件函数
Python bytes decode() 方法 https://www.cnblogs.com/wushuaishuai/p/7686265.html
Flask 四种响应类型 https://www.cnblogs.com/sysnap/p/6634544.html
flask中的response https://www.cnblogs.com/zhuchunyu/p/10466509.html
def success():
return jsonify({"code": SUCCESS_CODE, "msg": _(SUCCESS_MSG)})
# jsonify返回Response类型给前端,后端如果要截取,则要要解析成字符串或者字典才能直接使用
result = success()
#logger.info("result={},type={}".format(result,type(result)))
#logger.info("result.data={},type={}".format(result.data,type(result.data)))
#logger.info("result.status={},type={}".format(result.status,type(result.status)))
#logger.info("result.headers={}".format(result.headers))# 提取Response类型中的data,data是bytes类型,用decode(或者str())转为字符串,随后转为dict类型
result_encode = json.loads(result.data.decode('UTF-8','strict'))
# logger.info("result_encode={},type={}".format(result_encode,type(result_encode)))
if result_encode["code"] != SUCCESS_CODE:
return result