I'm trying to read Json from a file, than convert to list.But i'm getting error at the beginnig of code, Json.load(). I couldn't figure out. Thanks.
import json
with open("1.txt") as contactFile:
data=json.load(contactFile.read())
1.txt:
[{"no":"0500000","name":"iyte"},{"no":"06000000","name":"iyte2"}]
Error:
File "/usr/lib/python2.7/json/__init__.py", line 286, in load
return loads(fp.read(),
AttributeError: 'str' object has no attribute 'read'
open("1.txt", 'r').'r'is the default.