我有一个Python脚本,按照所述顺序执行以下操作:
这是我正在努力的第四部分。以下代码一直有效,直到第4阶段停止其余工作:
#!/usr/bin/python
import re
import sys
import cgi
# Compare the cleaned up list of IPs against the botwatch
# list and output the results to a new file.
new_list = set()
outfile = open("final_downloads/malicious_ips", "w")
for line in open("final_downloads/ip_list_clean", "r")
if line in open("/var/www/botwatch.txt", "r")
outfile.write(line)
new_list.add(line)
outfile.close()
关于为什么最后一节不起作用的任何想法?事实上,它阻止了整个工作。
答案 0 :(得分:1)
您在上一节中遗漏了一些冒号。试试这个:
new_list = set()
outfile = open("final_downloads/malicious_ips", "w")
for line in open("final_downloads/ip_list_clean", "r"):
if line in open("/var/www/botwatch.txt", "r"):
outfile.write(line)
new_list.add(line)
outfile.close()