我想将一个列表写入文件,并将该文件的内容读回列表中.我可以使用simplejson将列表写入文件,如下所示:
f = open("data.txt","w")
l = ["a","b","c"]
simplejson.dump(l,f)
f.close()
Run Code Online (Sandbox Code Playgroud)
现在回来读我的文件
file_contents = simplejson.load(f)
Run Code Online (Sandbox Code Playgroud)
但是,我猜file_contents是json格式.有没有办法将其转换为列表?
谢谢.