質問編集履歴

8

文法修正

2020/10/28 09:28

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -102,4 +102,6 @@
102
102
 
103
103
 
104
104
 
105
+
106
+
105
107
  ![イメージ説明](29650fbf0a1cfa018edb09089bf2a8ce.png)

7

コード追加

2020/10/28 09:28

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -99,3 +99,7 @@
99
99
  AttributeError: 'Response' object has no attribute 'tex'
100
100
 
101
101
  ```
102
+
103
+
104
+
105
+ ![イメージ説明](29650fbf0a1cfa018edb09089bf2a8ce.png)

6

変更点追加

2020/10/28 09:17

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -54,7 +54,7 @@
54
54
 
55
55
  r = requests.get(url)
56
56
 
57
- data = json.loads(r.text
57
+ data = json.loads(r.tex)
58
58
 
59
59
  print(json.dumps(data, indent=1))
60
60
 
@@ -76,12 +76,26 @@
76
76
 
77
77
 
78
78
 
79
- File "<ipython-input-195-6ee2db1e03e3>", line 7
79
+ London,UK Tokyo,JP New York,US
80
80
 
81
- print(json.dumps(data, indent=1))
81
+ ---------------------------------------------------------------------------
82
82
 
83
- ^
83
+ AttributeError Traceback (most recent call last)
84
84
 
85
+ <ipython-input-203-dcc2a9de9f7b> in <module>
86
+
87
+ 4 url = api.format(city=name, key=apikey)
88
+
85
- SyntaxError: invalid syntax
89
+ 5 r = requests.get(url)
90
+
91
+ ----> 6 data = json.loads(r.tex)
92
+
93
+ 7 print(json.dumps(data, indent=1))
94
+
95
+ 8 print("+ 都市 =", data["name"])
96
+
97
+
98
+
99
+ AttributeError: 'Response' object has no attribute 'tex'
86
100
 
87
101
  ```

5

文法修正

2020/10/28 09:14

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -54,7 +54,9 @@
54
54
 
55
55
  r = requests.get(url)
56
56
 
57
- data = json.loads(r.text)
57
+ data = json.loads(r.text
58
+
59
+ print(json.dumps(data, indent=1))
58
60
 
59
61
  print("+ 都市 =", data["name"])
60
62
 
@@ -74,26 +76,12 @@
74
76
 
75
77
 
76
78
 
77
- London,UK Tokyo,JP New York,US
79
+ File "<ipython-input-195-6ee2db1e03e3>", line 7
78
80
 
79
- ---------------------------------------------------------------------------
81
+ print(json.dumps(data, indent=1))
80
82
 
81
- KeyError Traceback (most recent call last)
83
+ ^
82
84
 
83
- <ipython-input-140-8a8e428ed215> in <module>
84
-
85
- 5 r = requests.get(url)
86
-
87
- 6 data = json.loads(r.text)
88
-
89
- ----> 7 print("+ 都市 =", data["name"])
90
-
91
- 8 print("| 天気 =", data["weather"][0]["description"])
92
-
93
- 9 print("| 最低気温 =", k2c(data["main"]["temp_min"]))
94
-
95
-
96
-
97
- KeyError: 'name'
85
+ SyntaxError: invalid syntax
98
86
 
99
87
  ```

4

変更点追加

2020/10/28 09:09

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ご指摘、ご教授お願いします。
4
4
 
5
- ![![イメージ説明](3334d14d00b5e74dfc0fdbc28d96e0c1.png)](19ce18b21bf36b22f25af5ac403c4ae2.png)
5
+ ![イメージ説明](f5eedd3782bc069ad6501fff53fe6626.png)
6
6
 
7
7
  ```python
8
8
 
@@ -20,7 +20,9 @@
20
20
 
21
21
 
22
22
 
23
- api = f"http://api.openweathermap.org/data/2.5/forecast?q=Tokyo&APPID={apikey}"
23
+ api = "http://api.openweathermap.org/data/2.5/forecast?q={city}&APPID={key}"
24
+
25
+
24
26
 
25
27
  k2c =lambda k: k - 273.15
26
28
 

3

文法修正

2020/10/28 09:01

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ご指摘、ご教授お願いします。
4
4
 
5
-
5
+ ![![イメージ説明](3334d14d00b5e74dfc0fdbc28d96e0c1.png)](19ce18b21bf36b22f25af5ac403c4ae2.png)
6
6
 
7
7
  ```python
8
8
 

2

コード追加

2020/10/28 08:54

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -20,9 +20,7 @@
20
20
 
21
21
 
22
22
 
23
- api = "http://api.openweathermap.org/data/2.5/forecast?q=Tokyo&APPID={MMM}"
23
+ api = f"http://api.openweathermap.org/data/2.5/forecast?q=Tokyo&APPID={apikey}"
24
-
25
-
26
24
 
27
25
  k2c =lambda k: k - 273.15
28
26
 

1

コード追加

2020/10/28 08:49

投稿

PPAP_AWS
PPAP_AWS

スコア105

test CHANGED
File without changes
test CHANGED
@@ -80,20 +80,20 @@
80
80
 
81
81
  KeyError Traceback (most recent call last)
82
82
 
83
- <ipython-input-126-8a8e428ed215> in <module>
83
+ <ipython-input-140-8a8e428ed215> in <module>
84
-
85
- 2 print("London,UK", "Tokyo,JP", "New York,US")
86
-
87
- 3
88
-
89
- ----> 4 url = api.format(city=name, key=apikey)
90
84
 
91
85
  5 r = requests.get(url)
92
86
 
93
87
  6 data = json.loads(r.text)
94
88
 
89
+ ----> 7 print("+ 都市 =", data["name"])
90
+
91
+ 8 print("| 天気 =", data["weather"][0]["description"])
92
+
93
+ 9 print("| 最低気温 =", k2c(data["main"]["temp_min"]))
95
94
 
96
95
 
96
+
97
- KeyError: 'MMM'
97
+ KeyError: 'name'
98
98
 
99
99
  ```