@R2kip

Как получить nick из list?

Мне надо получить список по типу ["Verfyx","F1kuS1337" и т.д]

JSON
{
"members": [{
                        "nick": "Verfyx",
                        "on_server": "",
                        "permission": 2,
                        "played": 5719371
                    },
                    {
                        "nick": "F1kuS1337",
                        "on_server": "",
                        "permission": 1,
                        "played": 2667947
                    },
                    {
                        "nick": "_DanGamer",
                        "on_server": "",
                        "permission": 0,
                        "played": 7116962
                    },
                    {
                        "nick": "_Pastil_",
                        "on_server": "sur",
                        "permission": 0,
                        "played": 3992459
                    },
                    {
                        "nick": "NANAMINER",
                        "on_server": "",
                        "permission": 0,
                        "played": 2691407
                    },
                    {
                        "nick": "MPA3b",
                        "on_server": "sur",
                        "permission": 0,
                        "played": 2320798
                    },
                    {
                        "nick": "perega_sirat",
                        "on_server": "",
                        "permission": 0,
                        "played": 1490922
                    },
                    {
                        "nick": "Ali_Be",
                        "on_server": "",
                        "permission": 0,
                        "played": 1199383
                    },
                    {
                        "nick": "Squrvex",
                        "on_server": "",
                        "permission": 0,
                        "played": 1039390
                    },
                    {
                        "nick": "CoLdPuSsY",
                        "on_server": "",
                        "permission": 0,
                        "played": 550161
                    },
                    {
                        "nick": "Shones",
                        "on_server": "",
                        "permission": 0,
                        "played": 363913
                    },
                    {
                        "nick": "MIRK72",
                        "on_server": "",
                        "permission": 0,
                        "played": 276826
                    }
    ]
}
  • Вопрос задан
  • 89 просмотров
Решения вопроса 1
@n0tanumb3r
members = {
"members": [{
                        "nick": "Verfyx",
                        "on_server": "",
                        "permission": 2,
                        "played": 5719371
                    },
                    {
                        "nick": "F1kuS1337",
                        "on_server": "",
                        "permission": 1,
                        "played": 2667947
                    },
                    {
                        "nick": "_DanGamer",
                        "on_server": "",
                        "permission": 0,
                        "played": 7116962
                    },
                    {
                        "nick": "_Pastil_",
                        "on_server": "sur",
                        "permission": 0,
                        "played": 3992459
                    },
                    {
                        "nick": "NANAMINER",
                        "on_server": "",
                        "permission": 0,
                        "played": 2691407
                    },
                    {
                        "nick": "MPA3b",
                        "on_server": "sur",
                        "permission": 0,
                        "played": 2320798
                    },
                    {
                        "nick": "perega_sirat",
                        "on_server": "",
                        "permission": 0,
                        "played": 1490922
                    },
                    {
                        "nick": "Ali_Be",
                        "on_server": "",
                        "permission": 0,
                        "played": 1199383
                    },
                    {
                        "nick": "Squrvex",
                        "on_server": "",
                        "permission": 0,
                        "played": 1039390
                    },
                    {
                        "nick": "CoLdPuSsY",
                        "on_server": "",
                        "permission": 0,
                        "played": 550161
                    },
                    {
                        "nick": "Shones",
                        "on_server": "",
                        "permission": 0,
                        "played": 363913
                    },
                    {
                        "nick": "MIRK72",
                        "on_server": "",
                        "permission": 0,
                        "played": 276826
                    }
    ]
}

nicks = [] # Создаем пустой список

for member in members["members"]:
    nicks.append(member["nick"]) # Добавляем элемент "nick" в созданный ранее список

print(nicks) 
# ['Verfyx', 'F1kuS1337', '_DanGamer', '_Pastil_', 'NANAMINER', 'MPA3b', 'perega_sirat', 'Ali_Be', 'Squrvex', 'CoLdPuSsY', 'Shones', 'MIRK72']
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы