import os
import random
f = open('ips.txt', 'w')
for n in range(1200):
f.write('172.25.254.'+str(random.randint(1, 254))+'\n')
f.close()
f = open('ips.txt', 'r')
AllLines = [line.strip() for line in f.readlines()]
f.close()
Count = {}
for n in AllLines:
if n in Count:
Count[n] = Count[n] + 1
else:
Count[n] = 1
# CountNew = sorted(zip(Count.values(), Count.keys()), reverse=True)
# for n in range(10):
# print(CountNew[n][1])
print(sorted(Count.keys(), key=lambda x:Count[x], reverse=True))
Python实现IP计数排序
最新推荐文章于 2023-08-11 15:15:32 发布