我无法使用从网络获取的数据

I can't use the data I get from the web

我正在从网络获取数据,但我无法像 json 或字典一样使用它。

import requests
from bs4 import BeautifulSoup

url = "http://www.omdbapi.com/?apikey=73a4d84d&t=Tenet"
response = requests.get(url)
content = response.content
soup = BeautifulSoup(content,"html.parser")

print(soup["Title"])

您会收到 JSON 回复。您可以使用便捷的 Response.json() 方法对其进行反序列化。

import requests

url = "http://www.omdbapi.com/?apikey=73a4d84d&t=Tenet"
response = requests.get(url)
data = response.json() # same as data = json.loads(response.text) after import json
print(data)
print(data['Title'])