回答編集履歴

2

コードの変更

2018/01/06 14:46

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -8,23 +8,29 @@
8
8
 
9
9
  ```Python
10
10
 
11
- >>> hoge = input()
11
+ >>> def func():
12
12
 
13
- hogehoge
13
+ ... return 'hoge'
14
14
 
15
+ ...
16
+
17
+ >>> a = func()
18
+
15
- >>> hoge[0]
19
+ >>> a[0]
16
20
 
17
21
  'h'
18
22
 
19
- >>> hoge = input
23
+ >>>
20
24
 
25
+ >>> b = func
26
+
21
- >>> hoge[0]
27
+ >>> b[0]
22
28
 
23
29
  Traceback (most recent call last):
24
30
 
25
31
  File "<stdin>", line 1, in <module>
26
32
 
27
- TypeError: 'builtin_function_or_method' object is not subscriptable
33
+ TypeError: 'function' object is not subscriptable
28
34
 
29
35
  ```
30
36
 

1

追記

2018/01/06 14:46

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -1 +1,41 @@
1
1
  `weather_data = r.json` ⇒ `weather_data = r.json()` ですね。
2
+
3
+
4
+
5
+ 同様のエラーの再現
6
+
7
+ ---
8
+
9
+ ```Python
10
+
11
+ >>> hoge = input()
12
+
13
+ hogehoge
14
+
15
+ >>> hoge[0]
16
+
17
+ 'h'
18
+
19
+ >>> hoge = input
20
+
21
+ >>> hoge[0]
22
+
23
+ Traceback (most recent call last):
24
+
25
+ File "<stdin>", line 1, in <module>
26
+
27
+ TypeError: 'builtin_function_or_method' object is not subscriptable
28
+
29
+ ```
30
+
31
+
32
+
33
+ 質問の仕方について
34
+
35
+ ---
36
+
37
+ teratailには、上記のようにコードを見やすく表示する機能があります。
38
+
39
+ 質問編集画面を開き、コードを選択した状態で<code>ボタンを押してください。
40
+
41
+ 特にPythonの場合、インデントが崩れるとコードの意味が変わってしまいます。