京东二面笔试题 1) 生成一个大文件ip.txt,要求1200行,每行随机为172.25.254.1---172.25.254.254之间的一个ip地址; 2) 读取ip.txt文件统计这个文件中ip
importrandomimportcollectionswithopen("ip.txt","w",encoding="utf-8")asfile1:foriinrange(1200):ip="172.25.254."+str(random.randint(1,255))+"\n"file1.write(ip)try:withopen("ip.txt","r",encoding="utf-8")