擅长:python、mysql、java
<p>如<a href="https://www.programiz.com/python-programming/methods/dictionary/update" rel="nofollow noreferrer">here</a>所述,<code>update()</code>方法使用来自dictionary对象或键/值对的iterable对象的元素更新dictionary。您将收到一条错误消息,因为您试图更新字典,但没有指定与<code>temp_1</code>中的值关联的键</p>
<p>这应该可以做到:</p>
<pre><code>statement={}
for temp in cleaned_list:
key=temp[0]
statement.update({key:None})
if len(temp)==1:
value=key
statement.update({key:value})
elif len(temp) > 1:
values=temp[1:]
statement.update({key:values})
</code></pre>