@mirindanda

Как достать url?

{
"date": "2021-12-07",
"explanation": "very time two massive black holes collide, a loud chirping sound is broadcast out into the universe in gravitational waves. Humanity has only had the technology to hear these unusual chirps for the past seven years, but since then we have heard about 90 -- during the first three observing runs. Featured above are the spectrograms -- plots of gravitational-wave frequency versus time -- of these 90 as detected by the giant detectors of LIGO (in the USA), VIRGO (in Europe), and KAGRA (in Japan). The more energy received on Earth from a collision, the brighter it appears on the graphic. Among many science firsts, these gravitational-radiation chirps are giving humanity an unprecedented inventory of black holes and neutron stars, and a new way to measure the expansion rate of our universe. A fourth gravitational wave observing run with increased sensitivity is currently planned to begin in 2022 December.",
"hdurl": "https://apod.nasa.gov/apod/image/2112/GWaveCatalog...",
"media_type": "image",
"service_version": "v1",
"title": "Ninety Gravitational Wave Spectrograms and Counting",
"url": "https://apod.nasa.gov/apod/image/2112/GWaveCatalog..."
}

У меня есть такой json файл и мне надо достать ссылку из url
  • Вопрос задан
  • 88 просмотров
Решения вопроса 2
bravebug
@bravebug
import json

# если читаем из файлового объекта data.json
with open("data.json") as ff:
    data1 = json.load(ff)

print(data1["url"])

# если получили данные как строка в переменную data_string
data2 = json.loads(data_string)

print(data2["url"])
Ответ написан
Комментировать
print(s["url"])
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы