标签:文件 比较 pre 分析 今天 pen python3 class blog
#/usr/bin/python3
# 判断文件ip.txt中的ip是否在ip2.txt中
diff_ip = 0
alike_ip = 0
with open(‘ip.txt‘) as ip_file, open(‘ip2.txt‘) as ip2_file:
for ip in ip2_file:
if ip in ip_file:
print(‘%s 是昨天访问过! ‘ % ip.strip())
alike_ip += 1
else:
print(‘%s 昨天未访问过! ‘ % ip.strip())
diff_ip += 1
print("一共有%s 个ip是昨天访问而今天未访问\n一共有 %s 个ip 是昨天今天都访问了" % (diff_ip, alike_ip))
标签:文件 比较 pre 分析 今天 pen python3 class blog
原文地址:http://www.cnblogs.com/collglle/p/6553045.html