• 单接口构造大量数据


    方案一:用字典处理

    # -*- coding: UTF-8 -*-
    import json
    
    
    req = {"D":{"serviceId":"6000045","wName":["30000","add","","2020-04-20 23:59:59"],"autoWname":[],"originType":"1","form":[{"wId":"6661","wName":"priority","wType":"2","wVal":"30000","widgetValue":[],"param1":"","wDisplayCn":"30000","wDisplayEn":"30000"},{"wId":"6662","wName":"act","wType":"2","wVal":"add","widgetValue":[],"param1":"","wDisplayCn":"add","wDisplayEn":"add"},{"wId":"6664","wName":"edate","wType":"4","wVal":"2020-04-20 23:59:59","widgetValue":[],"param1":"","wDisplayCn":"2020-04-20 23:59:59","wDisplayEn":"2020-04-20 23:59:59"},{"wId":"177544","wName":"whiteList","wType":"14","wVal":"177544","wDisplayCn":"177544","wDisplayEn":"177544"}],"applyEmpId":"10237221","applyEmpName":"刘悦 10237221","applyEmpDept":"中兴通讯/系统产品/技术规划部/IT长沙开发部","applyEmpTel":"15*******85","applyDesc":"test","agentEmpId":"10237221","agentName":"刘悦 10237221","agentEmpDept":"中兴通讯/系统产品/技术规划部/IT长沙开发部","agentTel":"15*******85","agentEmail":"chen.youquan@zte.com.cn","approveNode":[{"nodeId":"152758319564235807727","nodeStage":"0","approvePolicy":"","nodeHandler":""},{"nodeId":"152758319766701758574","nodeStage":"100","approvePolicy":"","nodeHandler":""},{"nodeId":"152758320105108766536","nodeStage":"202","approvePolicy":"3","nodeHandler":"6092002736"},{"nodeId":"152758320513702624990","nodeStage":"300","approvePolicy":"3","nodeHandler":"auto_open"},{"nodeId":"152758330059328099235","nodeStage":"400","approvePolicy":"","nodeHandler":""}],"lv3AuditorId":"","lv3Auditor":"","lv4AuditorId":"","bizAuditor":"陈有权 6092002736","bizAuditorId":"6092002736","bizOpener":"自动开通","bizOpenerId":"auto_open","nodeInform":"","areaId":"","areaName":"","agentFlag":"1","lvNAuditorId":[],"applyId":"REQX10000580306"},"EU":"string","L":"2052","LA":"string","P":{"ENDTM":"string","LSTTM":"string","PNO":"string","PSIZE":"string","STTM":"string","TL":"string"},"TT":"3","UT":"01"}
    
    row_01 = {"wId": "211144","wVal": "test2@yahoo.com","wTableId": "177544","wTableRowId": 1,"wName": "mail","wType": "2","widgetValue": [],
    "wDisplayCn": "test2@yahoo.com","wDisplayEn": "test2@yahoo.com","modifyFlag": "Y"}
    row_02 = {"wId": "219544","wVal": "ZTE001","wTableId": "177544","wTableRowId": 1,"wName": "orgName","wType": "2","widgetValue": [],
    "wDisplayCn": "ZTE001","wDisplayEn": "ZTE001","modifyFlag": "Y"}
    row_03 = {"wId": "227944","wVal": "测试_张三","wTableId": "177544","wTableRowId": 1,"wName": "name","wType": "2","widgetValue": [],
    "wDisplayCn": "测试_张三","wDisplayEn": "测试_张三","modifyFlag": "Y"}
    row_04 = {"wId": "236344","wVal": "18576695226","wTableId": "177544","wTableRowId": 1,"wName": "phone","wType": "2",
    "widgetValue": [],"wDisplayCn": "18576695226","wDisplayEn": "18576695226","modifyFlag": "Y"}
    
    for i in range(1,1000):
      row_01["wVal"] = "test" + str(i) + "@yahoo.com"
    
      row_01["wTableRowId"] = i
      row_02["wTableRowId"] = i
      row_03["wTableRowId"] = i
      row_04["wTableRowId"] = i
    
      req["D"]["form"].extend([row_01,row_02,row_03,row_04])
    
    str_all = json.dumps(req, ensure_ascii=False)
    
    file_name = u'test_req_chenyouquan.json'
    with open(file_name,'w') as file_object:
    file_object.write(str_all)
    
     
    

    方案二:当做纯粹字符串处理

    # -*- coding: UTF-8 -*-
    
    str_head = """{"D":{"serviceId":"6000045","wName":["30000","add",null,"2020-04-20 23:59:59"],"autoWname":[],"originType":"1","form":[{"wId":"6661","wName":"priority","wType":"2","wVal":"30000","widgetValue":[],"param1":null,"wDisplayCn":"30000","wDisplayEn":"30000"},{"wId":"6662","wName":"act","wType":"2","wVal":"add","widgetValue":[],"param1":null,"wDisplayCn":"add","wDisplayEn":"add"},{"wId":"6664","wName":"edate","wType":"4","wVal":"2020-04-20 23:59:59","widgetValue":[],"param1":null,"wDisplayCn":"2020-04-20 23:59:59","wDisplayEn":"2020-04-20 23:59:59"},{"wId":"177544","wName":"whiteList","wType":"14","wVal":"177544","wDisplayCn":"177544","wDisplayEn":"177544"},"""
    str_end = """],"applyEmpId":"10237221","applyEmpName":"刘悦 10237221","applyEmpDept":"中兴通讯/系统产品/技术规划部/IT长沙开发部","applyEmpTel":"15*******85","applyDesc":"test","agentEmpId":"10237221","agentName":"刘悦 10237221","agentEmpDept":"中兴通讯/系统产品/技术规划部/IT长沙开发部","agentTel":"15*******85","agentEmail":"chen.youquan@zte.com.cn","approveNode":[{"nodeId":"152758319564235807727","nodeStage":"0","approvePolicy":null,"nodeHandler":""},{"nodeId":"152758319766701758574","nodeStage":"100","approvePolicy":null,"nodeHandler":""},{"nodeId":"152758320105108766536","nodeStage":"202","approvePolicy":"3","nodeHandler":"6092002736"},{"nodeId":"152758320513702624990","nodeStage":"300","approvePolicy":"3","nodeHandler":"auto_open"},{"nodeId":"152758330059328099235","nodeStage":"400","approvePolicy":null,"nodeHandler":""}],"lv3AuditorId":"","lv3Auditor":"","lv4AuditorId":"","bizAuditor":"陈有权 6092002736","bizAuditorId":"6092002736","bizOpener":"自动开通","bizOpenerId":"auto_open","nodeInform":"","areaId":null,"areaName":null,"agentFlag":"1","lvNAuditorId":[],"applyId":"REQX10000580306"},"EU":"string","L":"2052","LA":"string","P":{"ENDTM":"string","LSTTM":"string","PNO":"string","PSIZE":"string","STTM":"string","TL":"string"},"TT":"3","UT":"01"}"""
    str_mid = """{"wId":"211144","wVal":"test2@yahoo.com","wTableId":"177544","wTableRowId":1,"wName":"mail","wType":"2","widgetValue":[],"wDisplayCn":"test2@yahoo.com","wDisplayEn":"test2@yahoo.com","modifyFlag":"Y"},{"wId":"219544","wVal":"ZTE001","wTableId":"177544","wTableRowId":1,"wName":"orgName","wType":"2","widgetValue":[],"wDisplayCn":"ZTE001","wDisplayEn":"ZTE001","modifyFlag":"Y"},{"wId":"227944","wVal":"测试_张三","wTableId":"177544","wTableRowId":1,"wName":"name","wType":"2","widgetValue":[],"wDisplayCn":"测试_张三","wDisplayEn":"测试_张三","modifyFlag":"Y"},{"wId":"236344","wVal":"18576695226","wTableId":"177544","wTableRowId":1,"wName":"phone","wType":"2","widgetValue":[],"wDisplayCn":"18576695226","wDisplayEn":"18576695226","modifyFlag":"Y"},"""
    
    str_mids = ''
    for i in range(1,500):
      str1 = 'test' + str(i) + "@yahoo.com"
      str2 = ',"wTableRowId":' + str(i)
      str3 = str_mid.replace('test2@yahoo.com',str1)
      str3 = str3.replace(',"wTableRowId":1',str2)
      # print(str3)
    
      str_mids =str_mids + str3
    
    str_mids = str_mids[0:-1]
    
    str_all = str_head + str_mids + str_end
    
    file_name = u'test_req_chenyouquan.json'
    with open(file_name,'w') as file_object:
        file_object.write(str_all)
    

      

  • 相关阅读:
    2018-2019-2 20165235 《网络对抗技术》 Exp6 信息搜集与漏洞扫描
    2018-2019 20165235 网络对抗 Exp5 MSF基础
    2018-2019 20165235 网络对抗 Exp4 恶意代码分析
    2018-2019-3 网络对抗技术 20165235 Exp3 免杀原理与实践
    2018-2019-2 20165235《网络对抗技术》Exp2 后门原理与实践
    Exp1 PC平台逆向破解 20165235 祁瑛
    2018-2019 20165235 网络对抗技术 Exp0:kali的安装
    20165302 Exp9 Web安全基础
    20165302 Exp 8 Web基础
    2018-2019-2 20165302 Exp7 网络欺诈防范
  • 原文地址:https://www.cnblogs.com/yahutiaotiao/p/12631968.html
Copyright © 2020-2023  润新知