标签:port import 字符串 int bsp 结果 read 文件的 data
--------将任何类型都转换为json字符串
方法dumps
import json dic={"name":"abc"} data = json.dumps(dic) print(type(data),data)
运行结果:
<class ‘str‘> {"name": "abc"} Process finished with exit code 0
----对文件的操作
方法loads
import json f_read = open("a","r") data = json.loads(f_read.read()) print(data["name"])
运行结果:
abc
Process finished with exit code 0
标签:port import 字符串 int bsp 结果 read 文件的 data
原文地址:https://www.cnblogs.com/liujinjing521/p/11299209.html