CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day11/json2.py
Views: 729
1
"""
2
写入JSON文件
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-13
7
"""
8
9
import json
10
11
teacher_dict = {'name': '白元芳', 'age': 25, 'title': '讲师'}
12
json_str = json.dumps(teacher_dict)
13
print(json_str)
14
print(type(json_str))
15
fruits_list = ['apple', 'orange', 'strawberry', 'banana', 'pitaya']
16
json_str = json.dumps(fruits_list)
17
print(json_str)
18
print(type(json_str))
19
20