#!/usr/bin/python
data = open("/home/mia/Desktop/results/all-nodup.txt", "r")
fd = open("/home/mia/Desktop/results/all-filter.txt", "w")
last_time = 0.0
last_ip = None
last_hash = None
row = data.read()
for line in row:
timestamp, ip, hash_value = line.split()
if ip==last_ip and hash_value==last_hash:
if float(timestamp) - float(last_time) >= 5.0:
fd.write("%s\t%s\t%s\n" % (str(timestamp), str(ip), str(hash_value)))
last_time, last_ip, last_hash = timestamp, ip, hash_value
else:
fd.write("%s\t%s\t%s\n" % (str(timestamp), str(ip), str(hash_value)))
last_time, last_ip, last_hash = timestamp, ip, hash_value
fd.close()
這是我整個的代碼,我去結果/目錄下運行:python filter.py
我得到一個錯誤信息:python: can't open file 'filter.py': [Errno 2] No such file or directory
Python不能打開文件
但其它腳本可以被執行,所以Python工作正常,也許我應該在這種情況下導入一些東西?
不改變目錄的路徑,這是什麼'LS filter.py'說明了什麼?怎麼樣'head -1 filter.py'? – bukzor