【发布时间】:2021-06-26 15:32:37
【问题描述】:
我的项目需要一个 JSON 文件来记住一串单词。代码转换一个列表:
lst = ['Hello', ' there', ' world!']
转换成 JSON 文件上的字符串。它通过使用代码来做到这一点:
lst = "".join(lst)
jsonFile = open("example.json", "w")
jsonFile.write(json.dumps(lst))
jsonFile.close()
新的example.json:
"Hello there world!"
然后如何将example.json 转换回lst 作为可用列表?
【问题讨论】: