回答編集履歴
1
追記
test
CHANGED
@@ -1 +1,55 @@
|
|
1
1
|
data["forecasts"][0]['temperature']とかがそれのようです。最低と最高、摂氏と華氏で見れるようですがNoneが入るときもあるようです。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
### 追記
|
6
|
+
|
7
|
+
簡単にやってみました。
|
8
|
+
|
9
|
+
```python
|
10
|
+
|
11
|
+
import requests
|
12
|
+
|
13
|
+
import json
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
def get_weather():
|
18
|
+
|
19
|
+
url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
|
20
|
+
|
21
|
+
payload = {'city': '230010'}
|
22
|
+
|
23
|
+
data = requests.get(url, params = payload).json()
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
for weather in data['forecasts']:
|
28
|
+
|
29
|
+
if weather['temperature']['min'] is None:
|
30
|
+
|
31
|
+
print("最低気温なし")
|
32
|
+
|
33
|
+
else:
|
34
|
+
|
35
|
+
print(weather['temperature']['min']['celsius'])
|
36
|
+
|
37
|
+
if weather['temperature']['max'] is None:
|
38
|
+
|
39
|
+
print("最高気温なし")
|
40
|
+
|
41
|
+
else:
|
42
|
+
|
43
|
+
print(weather['temperature']['max']['celsius'])
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
print("愛知県名古屋市の" + weather['dateLabel'] + "の天気は" + weather['telop'])
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
if __name__ == "__main__":
|
52
|
+
|
53
|
+
get_weather()
|
54
|
+
|
55
|
+
```
|