Answer the question
In order to leave comments, you need to log in
API Visual program select in Edit from Json?
Hello everyone, guys, I’ll say right away that I’m new to Python, I switched to it from Delphi, since there is a need to work with https, well, that’s not the point. The thing is, I’m writing a visual program, I received the form, I also receive data, I insert data into labels, etc., the program receives a Json list with parameters, but I can’t get some parameters and therefore the program crashes, please see how to fix it or what to add or remove , in other words, show the selection algorithm in Json, iterate through all the parameters and display the necessary ones in labels, thanks in advance I
use
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from form import Ui_Dialog
import requests
import json
from bs4 import BeautifulSoup
JSONhttps://zkillboard.com/api/stats/characterID/93232991/
————————————————————————
r = requests.get(CHARACTER_URL + chart, headers=HEADERS)
res = r.json()
ui.label1.setText('User ID : ' + json.dumps(res['info']['id'], indent=2))
ui.label2.setText('User Type : ' + json.dumps(res['info']['type'], indent=2))
ui.label3.setText('User Name : ' + json.dumps(res['info']['name'], indent=2))
ui.label4.setText('User SecStatus : ' + json.dumps(res['info']['secStatus'], indent=2))
Answer the question
In order to leave comments, you need to log in
response = requests.get(CHARACTER_URL + chart, headers=HEADERS)
json_data = response.json() # Здесь ты уже получаешь json
ui.label1.setText('User ID : {}'.format(json_data['info']['id']))
ui.label2.setText('User Type : {}'.format(json_data['info']['type']))
ui.label3.setText('User Name : {}'.format(json_data['info']['name']))
ui.label4.setText('User SecStatus : {}'.format(json_data['info']['secStatus']))
# Для вывода строк старайся не использовать сложение строк "+"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question