Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code failed JSON KeyError
#2
desc = items.get("desc") # the default value is None
desc = items.get("desc", '') # the default value is empty str ''
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Code failed JSON KeyError - by popps - Jan-15-2021, 02:47 PM
RE: Code failed JSON KeyError - by buran - Jan-15-2021, 03:24 PM
RE: Code failed JSON KeyError - by popps - Jan-15-2021, 03:36 PM
RE: Code failed JSON KeyError - by buran - Jan-15-2021, 03:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Request for Python code - Features extraction from JSON file (cuckoo) thinker 1 2,235 Apr-07-2021, 04:40 PM
Last Post: Larz60+
  API JSON response missing list gives keyerror rolfmadsen 3 3,538 Mar-28-2020, 10:12 AM
Last Post: buran
  json.dumps save some unicode chars as code, not char buran 1 2,952 Aug-02-2018, 04:02 PM
Last Post: buran

Forum Jump:

User Panel Messages

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