S
S
Sergey Yavin2019-10-23 17:40:48
Python
Sergey Yavin, 2019-10-23 17:40:48

How to get a Python 3 dict?

Good evening. I am writing a parser and when writing data to Excel it gives an error TypeError: string indices must be integers I figured out that when I assign a dictionary (dict) to a variable, this variable becomes str. Why is this happening?

import requests

response = requests.get("https://jcmellrudo.top/LiveFeed/GetChampZip?lng=ru&champ=1252965&partner=8&tf=10000")
fight_all = response.json()

rez = fight_all["Value"]["G"][1]["SC"]["S"][1]["Value"]
rez2 = rez["DI"]
print(rez2)
print(type(rez))
print(type(fight_all))

I need to leave a dictionary for further transfer to the method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Drill, 2019-10-23
@sjaserds

import requests
import json

response = requests.get("https://jcmellrudo.top/LiveFeed/GetChampZip?lng=ru&champ=1252965&partner=8&tf=10000")
fight_all = response.json()

rez = fight_all["Value"]["G"][1]["SC"]["S"][1]["Value"]

for i in json.loads(rez):
    print(i["DI"])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question