更新
This commit is contained in:
20
Python-100-Days/Day01-15/Day11/json2.py
Normal file
20
Python-100-Days/Day01-15/Day11/json2.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
|
||||
写入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))
|
||||
Reference in New Issue
Block a user