Pythonで天気予報データーを取得しようとするプログラムを
書いているのですが、なぜか、データーをjson形式で取得しようとするとエラー
となってしまいます。何がいけないのかさっぱりわからない状態です。
python
1import requests 2 3r = requests.get('http://wether.livedoor.com/forecast/webservice/json/vl?city=130010') 4print(r.status_code) 5print(r.text[:500]) 6print(r.json()) #ここでエラーとなってしまいます。 7 8''' 9tmp = r.json() #このようにしてもエラーとなってしまいます。 10'''
エラー内容↓
Traceback (most recent call last): File ".\test.py", line 6, in <module> print(r.json()) File "C:\Users\yamada\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 897, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\yamada\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 348, in loads return _default_decoder.decode(s) File "C:\Users\yamada\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\yamada\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 4)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。