Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'indices': 0.07; 'json': 0.07; 'subject:file': 0.07; 'received:internal': 0.09; 'skip:\\ 30': 0.09; 'subject:using': 0.09; 'typeerror:': 0.09; 'subject:python': 0.14; 'wed,': 0.15; '23,': 0.16; 'integers,': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'wrote:': 0.16; 'string': 0.17; 'appears': 0.23; 'header:In-Reply- To:1': 0.24; '(most': 0.24; 'figure': 0.27; 'str': 0.29; 'character': 0.29; 'error.': 0.31; 'traceback': 0.33; 'file': 0.34; 'to:addr:python-list': 0.35; 'really': 0.35; 'list': 0.35; 'should': 0.37; 'received:10': 0.37; 'subject:: ': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.39; 'data': 0.40; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.62; 'square': 0.76 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=VymlVsP8kP4DDMUIXIcv7NpIVqc=; b=hRNY9a vnOBtAtqlco3Rv+bzT0RoHgAlP6g8qmtsjBtwAueeQMAZjZDYBGUV7ZrwWF2c1Uz qVEJjwgZIoKZ6XDE06Ae1abe7TWHiAW4Z1IHCKBi3kJTJjBet5c8Imb14vKB/8q0 L4pm/RBaFcFaDfiThfzEPPKYFnjz64+AJ179g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=VymlVsP8kP4DDMU IXIcv7NpIVqc=; b=BNj7U5CIjhcvUyKAlUI2aSpoGbYmrCB92XkKT0KXQSP+NQO xA9941iamwPyPpeDLhrXKIZKWbCxucAQRQRxGAkeps8qCoU22YVzw7SqbddiUW6l 24PRfi4loR7ROBCDsdOVKMb4m3lvtxv9ZnnAQouZSTyX9Fp3KUo/zsUPmR+o= X-Sasl-Enc: UFe3t+9aukdrs/Ms1G65PNHrU6dTYmZ2nT2JvF+VYg2R 1432784912 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-073992ec In-Reply-To: <75320b35-72b6-4aae-a47f-630bd7bef812@googlegroups.com> References: <11dbf982-efc1-4ef0-b286-e3d08ba5030e@googlegroups.com> <75320b35-72b6-4aae-a47f-630bd7bef812@googlegroups.com> Subject: Re: Decoding JSON file using python Date: Wed, 27 May 2015 23:48:32 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432784915 news.xs4all.nl 2876 [2001:888:2000:d::a6]:49235 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91346 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 > print('message {} \n\n'.format(message['Message'])) > TypeError: list indices must be integers, not str > karthik.sharma@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.