這是我的第一個問題在這裏問stackoverflow,我真的很期待成爲這個社區的一部分。我是程序新手,python是許多人推薦的第一個程序。Python解析日誌文件的IP地址和協議
反正。我有一個類似如下的日誌文件:
"No.","Time","Source","Destination","Protocol","Info"
"1","0.000000","120.107.103.180","172.16.112.50","TELNET","Telnet Data ..."
"2","0.000426","172.16.112.50","172.16.113.168","TELNET","Telnet Data ..."
"3","0.019849","172.16.113.168","172.16.112.50","TCP","21582 > telnet [ACK]"
"4","0.530125","172.16.113.168","172.16.112.50","TELNET","Telnet Data ..."
"5","0.530634","172.16.112.50","172.16.113.168","TELNET","Telnet Data ..."
而我想用Python,使它看起來像這樣的結果來分析日誌文件:
從IP 135.13.216.191協議字數: (IMF 1) (SMTP 38) (TCP 24)(總計:63)
我真的想一些HEL爲了解決這個問題,我應該採用什麼方法來使用列表並循環遍歷它或字典/元組?
在此先感謝您的幫助!
'135.13.216.191'從哪裏來的? – Eric
這只是一個例子,但它來自目標字段中的一行。 –