[英]AttributeError: 'dict' object has no attribute 'append' Trying to write to .JSON file
[英]AttributeError: 'dict' object has no attribute 'append' in json
Append 不適用於字典 object。 我的代碼如下:
with open (file) as f:
for line in f:
review = json.loads(line)
review.append((review['reviewText'],review['overall']))#append is not working
review[5]
字典 object 沒有append
方法。 您可以將鍵、值添加到字典中,如下所示:
review["you_key"] = your_value
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.