擅长:python、mysql、java
<p>您是在一个文件中查找IP地址集,而不是在另一个文件中查找,反之亦然?</p>
<pre><code>with open(server_dhcp_file, 'rU') as f1, open(actual_hosts_file, 'rU') as f2
server_dhcp_reader = csv.reader(f1)
actual_host_reader = csv.reader(f2))
actual_host = {row[0] for row in actual_host_reader}
server_dhcp = {row[0] for row in server_dhcp_reader}
print "In actual but not server", actual_host - server_dhcp
print "In server but not actual", server_dhcp - actual_host
</code></pre>
<p><sup><sup>还请注意使用<code>with</code>在完成文件后立即关闭它们</sup></sup></p>