0

I want to use json library and run the code

import json

data = ''' {
    "name" : "Chuck",
    "phone": {
    "type" : "intl",
    "number" : "+1 734 355 4544"
     }
     "email" :{
     "hide" : "yes"
     } 
} '''

info = json.load(data)
print 'Name : ', info["name"]
print 'Hide:' , info["email"]["hide"]

It is showing the error "return loads(fp.read(), AttributeError: 'str' object has no attribute 'read' " Any solution for it? Edited version

Ali
  • 13
  • 5

1 Answers1

10

You've named your program json.py which conflicts with the built-in module json.

Rename your program to my_program.py and delete json.py and json.pyc from your directory.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308