簡體   English   中英

AttributeError: 'dict' object 在 json 中沒有屬性 'append'

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM