擅长:python、mysql、java
<p>您可以使用Python容器类型<code>set</code>,它只存储唯一的元素。下面的程序应该适合您:</p>
<pre><code>create a 'current' blacklist set
read the blacklist file IP's into the current set
create a 'delta' blacklist set
for each IP address in the log file
if not already in current blacklist
add the IP into the delta set
append (by writing) the delta set into the black list file
</code></pre>