Reputation: 4122
I have a dictionary with a single item in it created using json.loads()
. The data structure looks like this:
{"teamId":96}
When I attempt to access the dictionary value by using the following:
mydict = mydict[u'teamId']
I get the following error:
Traceback (most recent call last):
File "C:\Python27\counter.py", line 65, in <module>
print home_team[u'teamId']
TypeError: string indices must be integers
Can anyone explain to me what the issue is here? The code looks like it should work to me.
Thanks
Upvotes: 0
Views: 806
Reputation: 107287
You need json.dumps(you_file)
:
json.loads(json.dumps(your_file))
Upvotes: 1