Python Forum
Getting a certain value from inside brackets.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting a certain value from inside brackets.
#1
Hi there,
I'm a beginner so this problem might be very ease to solve.
Im doing a request to a device that responds with the following raw data:
[{u'address': {u'altitude': None,
               u'area': u'',
               u'buildingNumber': None,
               u'country': None,
               u'latitude': None,
               u'longitude': None,
               u'street': u'',
               u'zip': u''},
  u'id': 63XXXX,
  u'levelOfAccess': None,
  u'name': u'Schuppen',
  u'siteKey': u'YBCL-HXXX'}]
I basically want to save the value of 'siteKey', meaning YBCL-HXXX into a variable.
I had the problem before and could solve it using this method:
variableX = exampledata['siteKey']
With this method I get the following error:
TypeError: list indices must be integers, not str

I think it has to do with a different format of the raw data, because all my other raw data that I can put into a variable using the explained method is not [....] but only in {....}
I hope some of you can help me...
Best,
Leo
Reply


Messages In This Thread
Getting a certain value from inside brackets. - by LeoT - Feb-25-2021, 08:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [BeautifulSoup] Why does it turn inserted string's brackets into </>? Winfried 0 1,535 Sep-03-2022, 11:21 PM
Last Post: Winfried
  Reading list items without brackets and quotes jesse68 6 4,649 Jan-14-2022, 07:07 PM
Last Post: jesse68
  Data pulled from SQL comes in brackets nickzsche 3 2,681 Jan-04-2022, 03:39 PM
Last Post: ibreeden
  For Loop and Use of Brackets to Modify Dictionary in Tic-Tac-Toe Game new_coder_231013 7 2,274 Dec-28-2021, 11:32 AM
Last Post: new_coder_231013
  Removing internal brackets from a string Astrikor 4 2,688 Jun-04-2020, 07:54 PM
Last Post: Astrikor
  Taking brackets out of list in print statement pythonprogrammer 3 2,416 Apr-13-2020, 12:25 PM
Last Post: perfringo
  printing a list contents without brackets in a print statement paracelx 1 2,142 Feb-15-2020, 02:15 AM
Last Post: Larz60+
  Dictionnary brackets issue Reldaing 1 1,841 Nov-10-2019, 11:54 PM
Last Post: ichabod801
  how to remove brackets within a list A3G 17 18,305 Oct-16-2016, 02:34 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020