擅长:python、mysql、java
<p>这里的问题是<code>h</code>已经被创建了,稍后您可以通过调用<code>update()</code>方法向其添加</em>字符串。在</p>
<p>要解决这个问题,可以将<code>h</code>重新初始化为新的sha512哈希:</p>
<pre><code># ...
for t in texts:
h = hashlib.sha512() # < - here
h.update(t)
t_hash = str(h.hexdigest())
if t_hash == text_compare_hash:
bool_text_hash.append(True)
else:
bool_text_hash.append(False)
# ...
</code></pre>