19 lines
367 B
Python
19 lines
367 B
Python
"""
|
|
写入JSON文件
|
|
|
|
Version: 0.1
|
|
Author: 骆昊
|
|
Date: 2018-03-13
|
|
"""
|
|
|
|
import json
|
|
|
|
teacher_dict = {'name': '白元芳', 'age': 25, 'title': '讲师'}
|
|
json_str = json.dumps(teacher_dict)
|
|
print(json_str)
|
|
print(type(json_str))
|
|
fruits_list = ['apple', 'orange', 'strawberry', 'banana', 'pitaya']
|
|
json_str = json.dumps(fruits_list)
|
|
print(json_str)
|
|
print(type(json_str))
|