Advertisement
dimkiriakos

json

Oct 4th, 2021
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. x= {
  2. "name":"John", "age":30, "city":"New York"
  3. }
  4. #x =  '[{"name":"John", "age":"30", "city":"New York"}]'
  5. f=open('forfaits2.txt','w')
  6. f.write(json.dumps(x))
  7. f.close()
  8. f=open('forfaits2.txt')
  9. #print(f.read())
  10. g=f.read()
  11. print(g)
  12. print(type(g))
  13. # parse x:
  14. y = json.loads(g)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement