Python-100-Days/Day01-15/Day11/code/json2.py

21 lines
369 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))