Advertisement
pestiand82

Json file

Sep 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. import json
  2.  
  3. phonebook = {
  4.     "name":"Robert",
  5.     "phone":"062055588896"
  6. }
  7.  
  8. # write json file
  9. with open("phonebook.json", "w") as f:
  10.     json.dump(phonebook, f)
  11.  
  12. # read json file
  13. with open("phonebook.json") as f:
  14.     data = json.load(f)
  15.     print( data.get("name") )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement