python - 将多个列表写入 JSON 文件
问题描述
我可以将单个列表存储到 json 文件中以供以后使用。您如何将多个列表存储到 json 文件中。假设我想将用户名添加到文件中,并将用户名 + '@gmail.com" 作为另一个列表添加到同一个文件中。稍后您将如何从 json 文件中访问这两个列表?
import json
username = johnsmith91
storelist = []
storelist.append(username)
with open('username.json', 'a') as outfile:
json.dump(storelist, outfile)
解决方案
推荐阅读
- networking - 使用ansible根据网络显示特殊文件
- rest - 我应该在 REST 上使用 WebSockets 吗?
- c# - 为什么 MVC 绑定模型需要属性而不是字段
- javascript - 动态设置从 JavaScript 模块导出的变量
- python-3.x - python字节到字符串转换中的t,n是什么意思?
- r - 使用 R 包 DT 使用 autowidth 和 scrollX 渲染表格
- laravel - 将不同的数据库查询合并到一个查询中
- c# - 文件 packages.config.md5sum 的用途
- angular - 属性返回未定义
- html - width:100% 当你点击一个项目时