【文件属性】:
文件名称:Python数据的存储和读取 学习笔记
文件大小:26KB
文件格式:PDF
更新时间:2020-12-22 14:07:20
numbers python 存储
"""存储数据"""
# 使用模块json存储数据
# 防止程序停止运行时用户数据丢失
import json
numbers = [2, 3, 4, 5]
filename = 'numbers.json'
with open(filename, 'w') as f_obj:
# 写入模式
json.dump(numbers, f_obj)
import json
filename = 'numbers.json'
with open(filename) as f_obj:
# 读取模式
numbers = json.load(f_obj)
print(num