TypeError: string indices must be integers, not 'str'
{
"data": {
"teamStanding": [
{
"id": "team_1",
"score": 103,
"players": [
{
"user": {
"name": "player_1",
"id": "player_1"
},
"score": 35
},
{
"user": {
"name": "player_2",
"id": "player_2"
},
"score": 30
}
// и так далее...
]
},
// Другие команды...
]
}
}
import json
path = 'test.json'
with open(path, 'r') as file:
data = json.load(file)
for team in data["data"]["teamStanding"]:
if team["id"] == "team_1":
for player in team["players"]:
print(player["user"]["name"], player["score"])
import socket
import ssl
def test_connection(address):
certs_return = ""
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
try:
with socket.create_connection((address, 443), timeout=10) as sock:
with context.wrap_socket(sock, server_hostname=address) as ssock:
cert = ssock.getpeercert()
for (issuer, entry) in cert['issuer']:
certs_return += "{}={}\n".format(issuer, entry)
except Exception as e:
certs_return = "0"
return certs_return