import json
name = {
'alex':[22,'M'],
'tony':[21,'F'],
}
name_after = json.dumps(name)
name_after = name_after.encode("utf-8") #区别于Python2
f = open("data_to_qq.txt","wb")
f.write(name_after)
f.close()
--------------------------------------------------------------------
读出数据
import json
f = open("data_to_qq.txt",'rb')
name = json.loads(f.read().decode("utf-8"))
f.close()
print(name['alex'])
print(type(name))