company_shenxinfu-9.27
1、查找两个文件中相同的IP地址
python代码:
// An highlighted block
with open("txt1","r") as f1:
list1 = f1.readlines()
list1 = set(list1)
with open("txt2","r") as f2:
list2 = f2.readlines()
list2 = set(list2)
same_data = list1.intersection(list2)
print(same_data)
for i in same_data:
print(i.strip())
open和with open区别:
使用open打开文件,必须要使用close关闭文件,所以,为了保证无论是否出错都能正确地关闭文件。
with open可以不用close()方法关闭文件,无论在文件使用中遇到什么问题都能安全的退出,即使发生错误,退出运行时环境时也能安全退出文件并给出报错信息。
open和with open用法和区别: https://blog.csdn.net/hguisu/article/details/7880288.
2、有一个vector容器中,存有1亿个qq号(不重复),如何快速挑选出其中奇数号码?
(Hash)
3、从1亿个qq号中如何快速挑选出其中已经知道的一个号码?
海量数据处理算法—Bit-Map
Bit Map算法链接: https://blog.csdn.net/hguisu/article/details/7880288.