获取的response的格式是bytes的数据类型,我需要转化成字符串或者字典使用,这里复习一下下面几个函数
1. json->string
str = json.dumps(json_type)
2. bytes->string
str = str(bytes_type, 'utf-8')
3. string/json->dict
dict = loads(str)
4. dict->json
json = dumps(dict)
5. 读取json文件->dict
dict = load(json)
6. dict->写入json文件
with open('test.json', 'w') as f:
json.dump(dict, f)
标签:string,python,bytes,json,API,dict,str,数据格式
From: https://www.cnblogs.com/sanmian/p/17142016.html