Decoding JSON file using python

random832 at fastmail.us random832 at fastmail.us
Wed May 27 23:48:32 EDT 2015



On Wed, May 27, 2015, at 19:51, Karthik Sharma wrote:
> I get the following error.
> 
> Traceback (most recent call last):
>   File "test_json.py", line 23, in <module>
>     print('message {} \n\n'.format(message['Message']))
> TypeError: list indices must be integers, not str
> karthik.sharma at aukksharma2:~$ vim test_json.py 

The string in data appears to be a json _list_ (note the first character
is a square bracket) - try message[0]['Message'].

You should really be able to figure this out yourself.



More information about the Python-list mailing list