......
2015-07-31 10:58:27: result is 23 seconds
2015-07-31 10:59:01: result is 57 seconds
2015-07-31 11:00:01: result is 57 seconds
2015-07-31 11:01:01: result is 57 seconds
2015-07-31 11:02:01: result is 57 seconds
2015-07-31 11:03:01: result is 57 seconds
2015-07-31 11:04:01: result is 57 seconds
2015-07-31 11:05:01: result is 57 seconds
2015-07-31 11:06:01: result is 57 seconds
2015-07-31 11:07:02: result is 58 seconds
2015-07-31 11:08:01: result is 57 seconds
2015-07-31 11:09:01: result is 57 seconds
2015-07-31 11:10:01: result is 57 seconds
2015-07-31 11:11:01: result is 57 seconds
2015-07-31 11:12:01: result is 57 seconds
2015-07-31 11:13:01: result is 57 seconds
2015-07-31 11:14:01: result is 57 seconds
2015-07-31 11:15:01: result is 57 seconds
2015-07-31 11:16:02: result is 58 seconds
2015-07-31 11:17:01: result is 57 seconds
2015-07-31 11:18:01: result is 57 seconds
2015-07-31 11:19:01: result is 57 seconds
...
Last active
August 29, 2015 14:26
-
-
Save ferstar/5414da941de0669bf490 to your computer and use it in GitHub Desktop.
统计差异时间出现次数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
log_path = "/tmp/log" | |
# 读取log内容 | |
with open(log_path, 'r') as f: | |
read_data = f.read() | |
# 去掉换行符 | |
list_data = read_data.split("\n")[1:-1] | |
# print(list_data) | |
list_num = [] | |
# 取得log秒值 | |
for item in list_data: | |
num = item.split(" ")[4] | |
list_num.append(num) | |
# 统计列表中相同的元素 | |
myset = set(list_num) | |
print("seconds\t\tcounts\r") | |
# 统计相同元素出现的次数 | |
for item in myset: | |
print(item + "\t\t%s\r" % list_num.count(item)) | |
print("log has %s items." % len(list_num)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment