更新时间:2023-09-08 08:36:46
CSV只是一种文本格式。逐行阅读,针对您的IP测试每一行。
CSV is just a text format. Read it line by line, test every line against your IP. Like
ip="192.168.1.1"
for line in csv_file:
if ip in line:
found = True
break
我有点担心您的自行车文件放在磁盘上。***将文件读入内存(首先在CSV文件中查找所有IP并放入列表中),然后再对列表进行检查,而不是为IP文件的每一行打开并遍历整个CSV文件。
I am a bit concerned against your cycling over file on the disk. Probably it is better to read files into memories (find all IPs in CSV file first and put in a list) and then check against the list instead of opening and iterating over whole CSV file for every line of IP file.