以下のようなコードがあります
python
1import json 2 3userloc = [] 4json_dict = [json.loads(line) for line in open('example.txt')] 5userloc.append([json_dict["user_id"],json_dict["business_id"]]) 6 7with open("example2.txt","w") as fw: 8 fw.writelines(userloc) 9
しかし、
python
1 File "get_userloc.py", line 10, in <module> 2 userloc.append([json_dict["user_id"],json_dict["business_id"]]) 3TypeError: list indices must be integers or slices, not str
このようなエラーをはかれてしまいます
どうすればよいでしょうか
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/28 12:10
2017/06/28 12:20 編集
2017/06/28 12:30
2017/06/28 12:49
2017/06/28 12:55
2017/06/28 13:15