将多个列表写入JSON文件

时间:2018-12-07 22:47:52

标签: 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)

0 个答案:

没有答案