python文件操作
1.文件操作
with open(“test.txt”,“r”,encoding=‘utf_ 8’) as f:
lines=f.readlines()
for line in lines:
print(line.rstrip())
test.txt内容:
序号 IP地址 访问次数 差量数
1 218.26.97.241 29942 0
2 92.63.197.100 28818 0
3 185.156.73.100 28338 0
4 185.156.73.67 27178 0
5 45.93.201.60 26413 0
6 92.63.196.151 23019 0
7 80.82.77.146 22637 0
8 31.10.5.211 21478 0
9 31.10.5.208 20305 0
10 80.82.70.217 19314 0
11 94.102.57.152 17568 0
12 80.82.65.201 17518 0
13 94.102.57.178 17029 0
14 176.113.115.162 15542 0
15 176.111.174.121 15462 0
16 176.111.174.100 15396 0
17 94.102.51.31 15236 0
18 152.89.198.146 14817 0
19 62.204.41.71 14703 0
20 62.204.41.72 14384 0
运行结果: