python ip地址频率扫描器
我正在尝试创建一个可以扫描日志的程序。然后显示日志中最频繁的地址。就是这样,但我需要一些帮助......
def analyse_logs():
open File = open('text.txt', "r")
readLines = openFile.read()
# pat = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
wordfreq = {}
for word in readLines.split():
if word not in wordfreq:
wordfreq[word] = 1
else:
wordfreq[word] += 1
print(wordfreq)
def extract_ip():
for line in string:
line = line.rstrip()
result = pattern.search(line)
def most_frequent():
counter = 0
num = List[0]
for i in List:
curr_frequency = List.count(i)
if (curr_frequency > counter):
counter = curr_frequency
num = i
return num
def main():
if__name__=="_main_":
I am trying to create a programme that will scan a log. The most freqeunt address in the log is then displayed. That is it but i need a bit of help with it please...
def analyse_logs():
open File = open('text.txt', "r")
readLines = openFile.read()
# pat = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}quot;)
wordfreq = {}
for word in readLines.split():
if word not in wordfreq:
wordfreq[word] = 1
else:
wordfreq[word] += 1
print(wordfreq)
def extract_ip():
for line in string:
line = line.rstrip()
result = pattern.search(line)
def most_frequent():
counter = 0
num = List[0]
for i in List:
curr_frequency = List.count(i)
if (curr_frequency > counter):
counter = curr_frequency
num = i
return num
def main():
if__name__=="_main_":
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这可能会更容易
I thought this might be easier