I'm practicing how to make a program using Python and suddenly I got an issue.
When I save a Dictionary type date into JSON, I use standard JSON library from Python and I can save data with the code below.
data = { 'a': 'aa' , 'b': 'bb' } with open('data.json', 'w', encoding='utf-8') as f: json.dump(data, f)
But, I can't save data into file with this.
data = { 'a': 'aa' , 'b': 'bb' } f = open('data.json', 'w', encoding='utf-8') json.dump(data, f) f.close()
I want to know the reason why upper one is working but lower one is not working.
Please explain it for me.
Thank you in advance.
没有评论:
发表评论