Student={ "name": "ruochen", "age": 18, "mobile": "18888888888" }- 案例v07
```python
import json # 此时student是一个dict格式内容,不是json student={ "name": "ruochen", "age": 18, "mobile": "18888888888" } print(type(student)) stu_json = json.dumps(student) print(type(stu_json)) print("JSON对象:{0}".format(stu_json)) stu_dict = json.loads(stu_json) print(type(stu_dict)) print(stu_dict) ```- 案例v08读取文件
```python
import json data = {"name":"hahaha", "age":12} with open("t.json", 'w') as f: json.dump(data, f) with open("t.json", 'r') as f: d = json.load(f) print(d) ```- t.json
```
{"name": "hahaha", "age": 12}
```原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。