我正在使用快速 API 创建小项目来获取 COVID 19 的每日报告。
import http.client ,time
from datetime import datetime
conn = http.client.HTTPSConnection("covid-19-data.p.rapidapi.com")
headers = {
'x-rapidapi-host': "covid-19-data.p.rapidapi.com",
'x-rapidapi-key': "xxxx"
}
# here I want to keep this date value is dynamic "today date"
conn.request("GET", "/report/country/name?date-format=YYYY-MM-DD&format=json&date=2020-06-12&name=uae", headers=headers)
res = conn.getresponse()
data = res.read()
如何使用今天的值使请求动态化datetime.today().strftime('%Y-%m-%d')