对于已经成功的1000页,也要修改。为了以后代码执行的工作量小点!进行切割:
作者:互联网
代码:【并不完善,需要手工修改一下!】
1 ''' 2 核心思想,就是通过不同的id号进行查找。不想要的,移除掉! 3 ''' 4 5 import json 6 def makes(): 7 i = 24999#截取后面的 8 # i = 49999# 截取前面的 9 cve_num0_file = open('D:/1hos/cvebase_ifo.json', "r") 10 cvesum = json.load(cve_num0_file) 11 # print(cvesum[i]['id']) 12 # while i > 25000:#截取前面的 13 while i > 0:#截取后面的 14 print(cvesum[i]['id']) 15 if int(cvesum[i]['id']) < 25000: 16 # cvesum[i].remove 17 del cvesum[i] 18 i -= 1#截取前面的 19 # i += 1#截取后面的 20 21 # with open('D:/1swqcve/cve_num1.json', "w+") as json_file: 22 # json_str = json.dumps(cve_num1_context, indent=4) 23 # json_file.write(json_str) 24 # json_file.close() 25 # print('\n************已经成功复制在cve_num1的内容************\n') 26 # print(cvesum) 27 with open('D:/1hos/cvebase_ifo4.json', "w") as json_file: 28 json_str = json.dumps(cvesum, indent=4) 29 json_file.write(json_str) 30 json_file.close() 31 # with open('D:/1swqcve/cve_num2.json', "w") as json_file: 32 # json_str = json.dumps(cvesum, indent=4) 33 # json_file.write(json_str) 34 # json_file.close() 35 # with open('D:/1swqcve/cve_num3.json', "w") as json_file: 36 # json_str = json.dumps(cvesum, indent=4) 37 # json_file.write(json_str) 38 # json_file.close() 39 # with open('D:/1swqcve/cve_num4.json', "w") as json_file: 40 # json_str = json.dumps(cvesum, indent=4) 41 # json_file.write(json_str) 42 # json_file.close() 43 # print("成功将cve编号写入4个json文件!\n") 44 if __name__=="__main__": 45 makes()
标签:小点,str,cvesum,json,代码执行,file,cve,open,1000 来源: https://www.cnblogs.com/hwpbetter/p/12631806.html