I am really confused with this part of the code:
newip = []
c = Counter()
for key, group in groupby(logfile, key=lambda e: e.split('.',1)[0]):
for entry in group:
c.update(re.findall(r'[0-9]+(?:\.[0-9]+){3}', entry))
newip.extend(ip for ip, cnt in c.items() if cnt > 10)
How to break these two lines into multiple lines, while doing the same task?
for key, group in groupby(logfile, key=lambda e: e.split('.',1)[0]):
...
newip.extend(ip for ip, cnt in c.items() if cnt > 10)
Now, I have two questions:
- Please explain what these two lines exactly do.
- How to break them into multiple lines, while carrying the same task?
Thanks and regards.
Aucun commentaire:
Enregistrer un commentaire