main
嗨,这是我的代码
输出是
import requests
url = "https://sameer-kumar-aztro-v1.p.rapidapi.com/"
querystring = {"sign":"aquarius","love":"today"}
headers = {
'x-rapidapi-key': "sds",
'x-rapidapi-host': "sameer-kumar-aztro-v1.p.rapidapi.com"
}
response = requests.request("POST", url, headers=headers, params=querystring)
print(response.text])
我想打印 "date_range" 或 "{"date_range": "Jan 20 - Feb 18", "current_date": "June 12, 2021", "description": "Nobody seems to have their lives ordered as well as you do today -- but what else is new? You should see if you can find the time to reach out and help those closest to you, but don't break your back!", "compatibility": "Taurus", "mood": "Thoughtful", "color": "Yellow", "lucky_number": "97", "lucky_time": "8am"}
" 。如何打印?
答案 0 :(得分:1)
request 允许我们通过执行获得 json 解码的响应
data = response.json()
然后你可以在python中以字典的形式访问它。
print(data["data_range"])
相关文档:https://2.python-requests.org/en/master/user/quickstart/#json-response-content