Python Forum
Response.json list indices must be integers or slices, not str [SOLVED]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Response.json list indices must be integers or slices, not str [SOLVED]
#1
Hello everybody,

I try to get the latest commit date from GitHub by using the GitHub API. This is the code I use:

import requests

response = requests.get("https://api.github.com/repos/quietvoid/dovi_tool/commits")
print(response.json()["date"])
I hoped to get the output:

2021-11-10T03:39:47Z
But I get the following:

Traceback (most recent call last):
  File "/home/pi/debug.py", line 4, in <module>
    print(response.json()["date"])
TypeError: list indices must be integers or slices, not str
I have a similar request for another project where I want to get the name and this works fine.
Can anyone help me?
Reply


Messages In This Thread
Response.json list indices must be integers or slices, not str [SOLVED] - by AlphaInc - Nov-13-2021, 11:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] list content check paul18fr 6 614 Jan-04-2024, 11:32 AM
Last Post: deanhystad
  tuple indices must be integers or slices, not str cybertooth 16 11,077 Nov-02-2023, 01:20 PM
Last Post: brewer32
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,091 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,181 Jun-09-2023, 06:56 PM
Last Post: kpatil
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,257 May-22-2023, 10:39 PM
Last Post: ICanIBB
  Loop through json file and reset values [SOLVED] AlphaInc 2 1,960 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
Question How to append integers from file to list? Milan 8 1,358 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  "TypeError: string indices must be integers, not 'str'" while not using any indices bul1t 2 1,931 Feb-11-2023, 07:03 PM
Last Post: deanhystad
  Error "list indices must be integers or slices, not str" dee 2 1,393 Dec-30-2022, 05:38 PM
Last Post: dee
  Name not found in response json NewbiePyt 4 1,014 Dec-29-2022, 11:12 AM
Last Post: buran

Forum Jump:

User Panel Messages

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