我正在尝试使用请求的json(),但收到错误消息:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我已经研究了有关此问题的线程,但是他们的解决方案并没有帮助解决该错误。
application/json;charset=utf-8
,因此它似乎是JSON格式。相关代码位:
r = requests.get("<url, it's very long>").json()
这是我打印(r.text)时输出的内容
{"total":"1","data":[{"states":"ID,MT,WY","latLong":"lat:44.59824417, long:-110.5471695","description":"On March 1, 1872, Yellowstone became the first national park for all
to enjoy the unique hydrothermal wonders. Today, millions of people come here each year to camp, hike, and enjoy the majesty of the park.","designation":"National Park","p
arkCode":"yell","id":"F58C6D24-8D10-4573-9826-65D42B8B83AD","directionsInfo":"Yellowstone National Park covers nearly 3,500 square miles in the northwest corner of Wyoming
(3% of the park is in Montana and 1% is in Idaho). Yellowstone has five entrance stations, and several are closed to regular vehicles during winter. It takes many hours to
drive between these entrances, so be sure to check the status of roads at the entrance you intend to use while planning your trip and before you arrive.","directionsUrl":"h
ttp:\/\/www.nps.gov\/yell\/planyourvisit\/directions.htm","fullName":"Yellowstone National Park","url":"https:\/\/www.nps.gov\/yell\/index.htm","weatherInfo":"Yellowstone's
weather can vary quite a bit, even in a single day. In the summer, daytime highs can exceed 70F (25C), only to drop 20 or more degrees when a thunderstorm rolls through. I
t can snow during any month of the year, and winter lows frequently drop below zero, especially at night. Bring a range of clothing options, including a warm jacket and rai
n gear, even in the summer.","name":"Yellowstone"}],"limit":"50","start":"1"}
这是我通过REST客户端(失眠)提出请求时返回的内容。
{
"total": "1",
"data": [
{
"states": "ID,MT,WY",
"latLong": "lat:44.59824417, long:-110.5471695",
"description": "On March 1, 1872, Yellowstone became the first national park for all to enjoy the unique hydrothermal wonders. Today, millions of people come here each year to camp, hike, and enjoy the majesty of the park.",
"designation": "National Park",
"parkCode": "yell",
"id": "F58C6D24-8D10-4573-9826-65D42B8B83AD",
"directionsInfo": "Yellowstone National Park covers nearly 3,500 square miles in the northwest corner of Wyoming (3% of the park is in Montana and 1% is in Idaho). Yellowstone has five entrance stations, and several are closed to regular vehicles during winter. It takes many hours to drive between these entrances, so be sure to check the status of roads at the entrance you intend to use while planning your trip and before you arrive.",
"directionsUrl": "http:\/\/www.nps.gov\/yell\/planyourvisit\/directions.htm",
"fullName": "Yellowstone National Park",
"url": "https:\/\/www.nps.gov\/yell\/index.htm",
"weatherInfo": "Yellowstone's weather can vary quite a bit, even in a single day. In the summer, daytime highs can exceed 70F (25C), only to drop 20 or more degrees when a thunderstorm rolls through. It can snow during any month of the year, and winter lows frequently drop below zero, especially at night. Bring a range of clothing options, including a warm jacket and rain gear, even in the summer.",
"name": "Yellowstone"
}
],
"limit": "50",
"start": "1"
}
到目前为止,r.get()。json()以及json.loads(r.text)都出现了相同的错误。