Python Forum
Dictionary value not recognized
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary value not recognized
#2
Indentation is wrong in first code.

You can not do a dot'ed call on a dictionary.
>>> results = {u'Relay1ON': 1800, u'Relay1OFF': u'0600'}
>>> results.Relay1ON
Traceback (most recent call last):
 File "<string>", line 301, in runcode
 File "<interactive input>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'Relay1ON'

>>> results['Relay1ON']
1800
>>> #Or get()
>>> results.get('Relay1ON', 'Not here')
1800
>>> results = {u'Relay1ON999': 1800, u'Relay1OFF': u'0600'}
>>> results.get('Relay1ON', 'Not here')
'Not here'
Reply


Messages In This Thread
Dictionary value not recognized - by marciokoko - Nov-16-2016, 03:48 PM
RE: Dictionary value not recognized - by snippsat - Nov-16-2016, 04:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is import cointegration_analysis a recognized module mitcht33 1 461 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  The term 'pip' is not recognized as the name of a cmdlet, function michaelnicol 1 664 Jul-16-2023, 11:12 PM
Last Post: deanhystad
  Index Function not recognized in Python 3 Peter_B_23 1 1,288 Jan-08-2023, 04:52 AM
Last Post: deanhystad
  TypeError: size; expecting a recognized type filling string dict a11_m11 0 2,561 Feb-10-2020, 08:26 AM
Last Post: a11_m11
  matplotlib isn't recognized after installation Pavel_47 5 2,880 Sep-18-2019, 07:01 PM
Last Post: snippsat
  how do i get y to be recognized in this comprehension? Skaperen 5 3,172 Aug-26-2019, 07:43 PM
Last Post: Skaperen
  why is my dictionary not recognized as such zatlas1 5 3,836 Jan-14-2019, 01:15 AM
Last Post: woooee
  pyserial-master installed bbut not recognized elwolv1 0 2,008 Jan-04-2019, 08:37 PM
Last Post: elwolv1
  How do I calculate the smallest value that is recognized as a difference when compari AFoeee 1 2,815 Oct-28-2018, 10:48 PM
Last Post: Gribouillis
  'videodigest' is not recognized as an internal or external command MM2018 2 2,819 Oct-12-2018, 02:43 PM
Last Post: MM2018

Forum Jump:

User Panel Messages

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