import json
data = {
'name' : 'FN',
'age' :21,
'email' : 'qq.com'
}
f1 = open("test1.json", 'w') ##此处为只写
json.dump(data, f1)
print('成功写入数据到文件!\n')
f1.close()
f2 = open('test1.json', encoding='utf-8')
line = f2.readline() ##这里可以读出来
d = json.loads(line)
name = d['name']
age = d['age']
email = d['email']
print(name, age, email)
f2.close()
f1是文件对象,这里的W是指文件对象还是文件?