【发布时间】:2018-04-12 08:52:30
【问题描述】:
我想将数据的值存储在我的 dict{} 字典中,但出现错误。
mydict= {}
for entity in entities:
if entity.entity_id.startswith('sensor'):
list = remote.get_state(api, entity.entity_id)
data = {list.attributes['friendly_name'] : list.state}
for key, val in data.items():
mydict+= {key:val}
我收到以下错误。
mydict+= {key:val}
TypeError: unsupported operand type(s) for +=: 'dict' and 'dict'
【问题讨论】:
标签: python dictionary for-loop store