def request_with_cookies(self, url=None, parameters=None):
        '''
        :param url: 请求的url
        :param parameters: 请求的参数
        :return: 返回响应对象

        e.g.
            post_data = {'username': '******', 'password': '******'}
            loginUrl = "http://test2.ishop-city.com/reconciliation/admin/user/login.json"
            testUrl = 'http://test2.ishop-city.com/reconciliation/repayCheck/gethuizong.json'
            http_object = HttpUrlConnection(get_cookie_url=loginUrl, get_cookie_request_data=post_data)
            result=http_object.request_with_cookies(testUrl)
            print(result.readlines())
        '''
        try:
            # 实例化HttpUrlConnection时如果没传url则将request_with_cookies的url赋给self.__url
            if self.__url is None:
                self.__url = url
            # 实例化HttpUrlConnection时如果没传parameters则将request_with_cookies的parameters赋给self.__url
            if self.__data is None:
                self.__data = parameters
            # 已带cookie的对象必须存在且请求的链接url必传
            if self.__opener is not None and self.__url is not None:
                html = self.__opener.open(self.__url, self.__data)
                return html
            else:
                return 0
        except Exception as e:
            logger.error(e)
            logger.exception(u"捕获到错误如下:")
    def request_with_cookies(self, url=None, parameters=None):
        '''
        :param url: 请求的url
        :param parameters: 请求的参数
        :return: 返回响应对象

        e.g.
            post_data = {'username': '******', 'password': '******'}
            loginUrl = "http://test2.ishop-city.com/reconciliation/admin/user/login.json"
            testUrl = 'http://test2.ishop-city.com/reconciliation/repayCheck/gethuizong.json'
            http_object = HttpUrlConnection(get_cookie_url=loginUrl, get_cookie_request_data=post_data)
            result=http_object.request_with_cookies(testUrl)
            print(result.readlines())
        '''
        try:
            # 实例化HttpUrlConnection时如果没传url则将request_with_cookies的url赋给self.__url
            if self.__url is None:
                self.__url = url
            # 实例化HttpUrlConnection时如果没传parameters则将request_with_cookies的parameters赋给self.__url
            if self.__data is None:
                self.__data = parameters
            # 已带cookie的对象必须存在且请求的链接url必传
            if self.__opener is not None and self.__url is not None:
                html = self.__opener.open(self.__url, self.__data)
                return html
            else:
                return 0
        except Exception as e:
            logger.error(e)
            logger.exception(u"捕获到错误如下:")
Ejemplo n.º 3
0
def generator():
    try:
        global code_list
        code_list = []
        if not code_list:
            get_district_code()
        id = code_list[random.randint(0, len(code_list))]['code']  # 地区项
        id += str(random.randint(1930, 2013))  # 年份项
        da = date.today() + timedelta(days=random.randint(1, 366))  # 月份和日期项
        id += da.strftime('%m%d')
        id += str(random.randint(100, 300))  # ,顺序号简单处理
        i = 0
        count = 0
        weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]  # 权重项
        check_code = {
            '0': '1',
            '1': '0',
            '2': 'X',
            '3': '9',
            '4': '8',
            '5': '7',
            '6': '6',
            '7': '5',
            '8': '5',
            '9': '3',
            '10': '2'
        }  # 校验码映射
        for i in range(0, len(id)):
            count += int(id[i]) * weight[i]
        id += check_code[str(count % 11)]  # 算出校验码
        return id
    except Exception as e:
        logger.error(e)
        logger.exception(u"捕获到错误如下:")
    def request(self):
        try:
            conn = http_client.HTTPConnection(self.__host, self.__port)
            if self.__method == "GET":
                self.path = self.__path + self.__parameters_urlencode_deal
                conn.request(self.__method, self.__path)
            if self.__method == "POST":
                if self.__headers == {"Content-type": "application/json"}:
                    conn.request(self.__method, self.__path, self.__jdata,
                                 self.__headers)
                if self.__headers == {
                        "Content-type": "application/x-www-form-urlencoded"
                }:
                    conn.request(self.__method, self.__path, self.__data,
                                 self.__headers)

            response = conn.getresponse()
            result_origin = response.read()
            try:
                result = result_origin.decode("gb2312").encode("utf8")
            except:
                result = result_origin
            return result
        except Exception as e:
            logger.error(e)
            logger.exception(u"捕获到错误如下:")
 def __init__(self, url=None, method="GET", parameters=None, cookie=None, headers={}, get_cookie_url=None,
              get_cookie_request_data=None,
              get_cookie_headers=[('User-agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')]):
     '''
     :param url: 请求使用的url,由于发送cookie的请求方法可以单独传url故此参数非必填。使用request方法请求时必填。
     :param method: 请求的方法
     :param parameters: 请求的参数
     :param cookie: cookie
     :param headers: 请求头
     :param get_cookie_url: 获取cookie的url,如果调用request_with_cookies时此参数必须传
     :param get_cookie_request_data: 获取cookie时需要传的参数
     :param get_cookie_headers: 获取cookie时需要加的请求头
     '''
     try:
         # 解析url
         if url is None:
             self.__url = None
         else:
             try:
                 if type(url) == bytes:
                     self.__url = url.decode("utf-8")
                 if type(url) == str:
                     self.__url = url
             except:
                 self.__url = url
             logger.debug(self.__url)
             scheme, rest = urllib_parse.splittype(self.__url)
             # 拆分域名和路径
             logger.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
             self.__host_absolutely, self.__path = urllib_parse.splithost(rest)
             host_list = self.__host_absolutely.split(":")
             if len(host_list) == 1:
                 self.__host = host_list[0]
                 self.__port = 80
             elif len(host_list) == 2:
                 self.__host = host_list[0]
                 self.__port = host_list[1]
         # 对所传参数进行处理
         self.__method = method
         self.__data = parameters
         self.__cookie = cookie
         if parameters != None:
             self.__parameters_urlencode_deal = urllib_parse.urlencode(parameters)
         else:
             self.__parameters_urlencode_deal = ""
         self.__jdata = simplejson.dumps(parameters, ensure_ascii=False)
         self.__headers = headers
         self.__opener = None
         self.__get_cookie_request_data = None
         if get_cookie_url is not None:
             cj = ckjar.CookieJar()
             self.__opener = urllib_request.build_opener(urllib_request.HTTPCookieProcessor(cj))
             self.__opener.addheaders = get_cookie_headers
             if get_cookie_request_data is not None:
                 self.__get_cookie_request_data = urllib_parse.urlencode(get_cookie_request_data).encode("utf-8")
             self.__opener.open(get_cookie_url, self.__get_cookie_request_data)
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 6
0
 def time_stamp(cls):
     try:
         # 格式化
         time_format1 = '%Y%m%d%H%M%S'
         return time.strftime(time_format1)
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 7
0
 def __init__(self):
     try:
         current_dir = os.getcwd()
         self.__ini_config_file = BASE_DIR + "/conf/" + "config.ini"
         self.__conf_config_file = BASE_DIR + "/conf/" + "config.conf"
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 8
0
 def __init__(self):
     try:
         current_dir = os.getcwd()
         self.__ini_config_file = BASE_DIR + "/conf/" + "config.ini"
         self.__conf_config_file = BASE_DIR + "/conf/" + "config.conf"
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 9
0
 def time_stamp(cls):
     try:
         # 格式化
         time_format1 = "%Y%m%d%H%M%S"
         return time.strftime(time_format1)
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def ytdyccrm_cancel_func(self):
     try:
         self.__data_dict["dt"] = self.__time_stamp
         sign_str = str(self.__data_dict["dt"]) + self.__data_dict["method"] + str(2.0) + self.__secretkey_value
         sign = Md5.md5(sign_str)
         self.__data_dict["sign"] = sign
         return self.__data_dict
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def __init__(self, interface_code, data_dict, secretkey_value):
     try:
         # 生成时间戳
         self.__time_stamp = TimeStamp.time_stamp()
         self.__data_dict = data_dict
         self.__secretkey_value = secretkey_value
         self.__interface_code = interface_code
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 12
0
 def ini_data(self, label, key, configFile=None):
     try:
         config = configparser()
         if configFile is None:
             configFile = self.__ini_config_file
         config.read(configFile)
         return config.get(label, key)
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 13
0
 def ini_data(self, label, key, configFile=None):
     try:
         config = configparser()
         if configFile is None:
             configFile = self.__ini_config_file
         config.read(configFile)
         return config.get(label, key)
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 14
0
 def md5(cls, strVar):
     try:
         # md5加密并小写化
         md5_var = hashlib.md5()
         md5_var.update(strVar.encode("utf-8"))
         # md5_var.update(strVar)
         sign = md5_var.hexdigest().lower()
         return sign
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def processing(self):
     try:
         processing_dict = dict()
         # 字典生成key和value的对应关系,value为方法对象而不是执行方法
         processing_dict["ytdyccrmcancel"] = self.ytdyccrm_cancel_func
         if self.__interface_code.decode("utf-8") in processing_dict:
             return processing_dict[self.__interface_code.decode("utf-8")]()
         else:
             return 0
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 16
0
 def request(self):
     try:
         if self.__method == "GET":
             response = requests.get(url=self.__url, params=self.__parameters)
         else:
             if self.__headers == {"Content-type": "application/json"}:
                 response = requests.post(url=self.__url, json=self.__parameters)
             else:
                 response = requests.post(url=self.__url, data=self.__parameters)
         return response
     except:
         logger.exception("发送普通请求错误:")
Ejemplo n.º 17
0
 def request_with_cookies(self):
     try:
         if self.__method == "GET":
             response = self.__session_object.get(url=self.__url, params=self.__parameters)
         else:
             if self.__headers == {"Content-type": "application/json"}:
                 response = self.__session_object.post(url=self.__url, json=self.__parameters)
             else:
                 response = self.__session_object.post(url=self.__url, data=self.__parameters)
         return response
     except:
         logger.exception("带cookies请求错误:")
 def urldecoded(self, data):
     try:
         data_list_first = data.split("&")
         data_list_second = list()
         for tmp in data_list_first:
             data_list_second.append(tmp.split("="))
             result = dict()
         for i in data_list_second:
             result[i[0]] = i[1]
         return result
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def request(self):
     try:
         if self.__method == "GET":
             response = requests.get(url=self.__url,
                                     params=self.__parameters)
         else:
             if self.__headers == {"Content-type": "application/json"}:
                 response = requests.post(url=self.__url,
                                          json=self.__parameters)
             else:
                 response = requests.post(url=self.__url,
                                          data=self.__parameters)
         return response
     except:
         logger.exception("发送普通请求错误:")
 def request_with_cookies(self):
     try:
         if self.__method == "GET":
             response = self.__session_object.get(url=self.__url,
                                                  params=self.__parameters)
         else:
             if self.__headers == {"Content-type": "application/json"}:
                 response = self.__session_object.post(
                     url=self.__url, json=self.__parameters)
             else:
                 response = self.__session_object.post(
                     url=self.__url, data=self.__parameters)
         return response
     except:
         logger.exception("带cookies请求错误:")
Ejemplo n.º 21
0
 def member_sign_up(browser_param, url, test_data):
     try:
         result_dict = dict()
         browser = browser_param
         browser.get(url)
         try:
             time.sleep(1)
             browser.find_element_by_xpath("//span[@class='li-left']")
             time.sleep(1)
             browser.find_element_by_xpath("//li[@data-url='../dyc/member_perfect_info.html']").click()
             time.sleep(1)
             browser.find_element_by_xpath("//img[@data-url='../dycnew/member-set.html']").click()
             time.sleep(1)
             browser.find_element_by_xpath("//button[@class='log_out']").click()
             time.sleep(1)
         except:
             logger.debug("未绑卡")
         browser.find_element_by_id("memberPhone").send_keys(test_data[0])
         browser.find_element_by_xpath("//a[@class='btn btn_verify verify_code']").click()
         time.sleep(2)
         sms_num = sms_object.get_sms_num_from_db(test_data[0])
         browser.find_element_by_id("inp_verify_code").send_keys(sms_num)
         browser.find_element_by_id("btn_login_success").click()
         time.sleep(3)
         try:
             browser.find_element_by_xpath("//li[@onclick='closeErrorInfoThree()']").click()
         except:
             logger.debug("已注册")
             result_dict["veri_point"] = None
             result_dict["sms_num"] = None
             return result_dict
         time.sleep(2)
         browser.find_element_by_id("memberName").send_keys(test_data[1])
         # 默认当前时间大约推30年
         memberIdNo = generator_const(test_data[2])
         browser.find_element_by_id("memberIdNo").send_keys(memberIdNo)
         # 推荐人手机号,非必填项
         # browser.find_element_by_id("referrerPhone").send_keys("phone_num")
         browser.find_element_by_xpath("//a[@class='btn btn_register']").click()
         time.sleep(2)
         browser.find_element_by_xpath("//li/a[@id='confirmBtn']").click()
         time.sleep(3)
         veri_point = browser.find_element_by_xpath("//div[@class='Balance-left']").text
         result_dict["veri_point"] = veri_point
         result_dict["sms_num"] = sms_num
         return result_dict
     except:
         logger.exception("发现错误")
Ejemplo n.º 22
0
 def conf_data(self, key, configFile=None):
     try:
         if configFile is None:
             configFile = self.__conf_config_file
         config_file = open(configFile, 'r')
         result = config_file.readlines()
         result_deal_list = []
         key_value_list = []
         for i in result:
             result_deal_list.append(i.strip('\n'))
         for j in result_deal_list:
             key_value_list.append(j.split('='))
         result_dict = dict(key_value_list)
         return result_dict[key]
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 23
0
 def conf_data(self, key, configFile=None):
     try:
         if configFile is None:
             configFile = self.__conf_config_file
         config_file = open(configFile, 'r')
         result = config_file.readlines()
         result_deal_list = []
         key_value_list = []
         for i in result:
             result_deal_list.append(i.strip('\n'))
         for j in result_deal_list:
             key_value_list.append(j.split('='))
         result_dict = dict(key_value_list)
         return result_dict[key]
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 24
0
def get_district_code():
    try:
        with open(DC_PATH) as file:
            data = file.read()
            district_list = data.split('\n')
        for node in district_list:
            # print node
            if node[10:11] != ' ':
                state = node[10:].strip()
            if node[10:11] == ' ' and node[12:13] != ' ':
                city = node[12:].strip()
            if node[10:11] == ' ' and node[12:13] == ' ':
                district = node[14:].strip()
                code = node[0:6]
                code_list.append({"state": state, "city": city, "district": district, "code": code})
    except Exception as e:
        logger.error(e)
        logger.exception(u"捕获到错误如下:")
    def request(self):
        try:
            conn = http_client.HTTPConnection(self.__host, self.__port)
            if self.__method == "GET":
                self.path = self.__path + self.__parameters_urlencode_deal
                conn.request(self.__method, self.__path)
            if self.__method == "POST":
                if self.__headers == {"Content-type": "application/json"}:
                    conn.request(self.__method, self.__path, self.__jdata, self.__headers)
                if self.__headers == {"Content-type": "application/x-www-form-urlencoded"}:
                    conn.request(self.__method, self.__path, self.__data, self.__headers)

            response = conn.getresponse()
            result_origin = response.read()
            try:
                result = result_origin.decode("gb2312").encode("utf8")
            except:
                result = result_origin
            return result
        except Exception as e:
            logger.error(e)
            logger.exception(u"捕获到错误如下:")
Ejemplo n.º 26
0
def get_district_code():
    try:
        with open(DC_PATH) as file:
            data = file.read()
            district_list = data.split('\n')
        for node in district_list:
            # print node
            if node[10:11] != ' ':
                state = node[10:].strip()
            if node[10:11] == ' ' and node[12:13] != ' ':
                city = node[12:].strip()
            if node[10:11] == ' ' and node[12:13] == ' ':
                district = node[14:].strip()
                code = node[0:6]
                code_list.append({
                    "state": state,
                    "city": city,
                    "district": district,
                    "code": code
                })
    except Exception as e:
        logger.error(e)
        logger.exception(u"捕获到错误如下:")
Ejemplo n.º 27
0
def generator():
    try:
        global code_list
        code_list = []
        if not code_list:
            get_district_code()
        id = code_list[random.randint(0, len(code_list))]['code']  # 地区项
        id += str(random.randint(1930, 2013))  # 年份项
        da = date.today() + timedelta(days=random.randint(1, 366))  # 月份和日期项
        id += da.strftime('%m%d')
        id += str(random.randint(100, 300))  # ,顺序号简单处理
        i = 0
        count = 0
        weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]  # 权重项
        check_code = {'0': '1', '1': '0', '2': 'X', '3': '9', '4': '8', '5': '7', '6': '6', '7': '5', '8': '5',
                      '9': '3', '10': '2'}  # 校验码映射
        for i in range(0, len(id)):
            count += int(id[i]) * weight[i]
        id += check_code[str(count % 11)]  # 算出校验码
        return id
    except Exception as e:
        logger.error(e)
        logger.exception(u"捕获到错误如下:")
 def __init__(self,
              url=None,
              method="GET",
              parameters=None,
              cookie=None,
              headers={},
              get_cookie_url=None,
              get_cookie_request_data=None,
              get_cookie_headers=[
                  ('User-agent',
                   'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')
              ]):
     '''
     :param url: 请求使用的url,由于发送cookie的请求方法可以单独传url故此参数非必填。使用request方法请求时必填。
     :param method: 请求的方法
     :param parameters: 请求的参数
     :param cookie: cookie
     :param headers: 请求头
     :param get_cookie_url: 获取cookie的url,如果调用request_with_cookies时此参数必须传
     :param get_cookie_request_data: 获取cookie时需要传的参数
     :param get_cookie_headers: 获取cookie时需要加的请求头
     '''
     try:
         # 解析url
         if url is None:
             self.__url = None
         else:
             try:
                 if type(url) == bytes:
                     self.__url = url.decode("utf-8")
                 if type(url) == str:
                     self.__url = url
             except:
                 self.__url = url
             logger.debug(self.__url)
             scheme, rest = urllib_parse.splittype(self.__url)
             # 拆分域名和路径
             logger.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
             self.__host_absolutely, self.__path = urllib_parse.splithost(
                 rest)
             host_list = self.__host_absolutely.split(":")
             if len(host_list) == 1:
                 self.__host = host_list[0]
                 self.__port = 80
             elif len(host_list) == 2:
                 self.__host = host_list[0]
                 self.__port = host_list[1]
         # 对所传参数进行处理
         self.__method = method
         self.__data = parameters
         self.__cookie = cookie
         if parameters != None:
             self.__parameters_urlencode_deal = urllib_parse.urlencode(
                 parameters)
         else:
             self.__parameters_urlencode_deal = ""
         self.__jdata = simplejson.dumps(parameters, ensure_ascii=False)
         self.__headers = headers
         self.__opener = None
         self.__get_cookie_request_data = None
         if get_cookie_url is not None:
             cj = ckjar.CookieJar()
             self.__opener = urllib_request.build_opener(
                 urllib_request.HTTPCookieProcessor(cj))
             self.__opener.addheaders = get_cookie_headers
             if get_cookie_request_data is not None:
                 self.__get_cookie_request_data = urllib_parse.urlencode(
                     get_cookie_request_data).encode("utf-8")
             self.__opener.open(get_cookie_url,
                                self.__get_cookie_request_data)
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_host(self):
     try:
         return self.__host
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_session_object(self):
     try:
         return self.__session_object
     except:
         logger.exception("获取带cookie对象错误")
 def get_path(self):
     try:
         return self.__path
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_opener(self):
     try:
         return self.__opener
     except:
         logger.exception(u"捕获到错误如下:")
 def get_parameters_urlencode_deal(self):
     try:
         return self.__parameters_urlencode_deal
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_path(self):
     try:
         return self.__path
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_host(self):
     try:
         return self.__host
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_parameters_urlencode_deal(self):
     try:
         return self.__parameters_urlencode_deal
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_opener(self):
     try:
         return self.__opener
     except Exception as e:
         logger.error(e)
         logger.exception(u"捕获到错误如下:")
 def get_opener(self):
     try:
         return self.__opener
     except:
         logger.exception(u"捕获到错误如下:")
Ejemplo n.º 39
0
 def get_session_object(self):
     try:
         return self.__session_object
     except:
         logger.exception("获取带cookie对象错误")
    def output_with_excel(self, template_file, sheet_count, data_list):
        '''
        :param template_file: 模板文件路径
        :param sheet_count: 模板文件容sheet的个数,比如5个sheet页通过这个参数可以指定就用3个
        :param data_list: 数据list,其中包含sheet页list,表头list,数据list
        本方法中均使用list进行数据操作,由于模板中第一行为标题,故插入数据的行数索引从1开始
        '''
        try:
            data = xlrd.open_workbook(template_file)
            sheet_name = data.sheet_names()
            sheet_list = list()
            # 将模板文件sheet对象存入sheet_list列表
            for i in range(sheet_count):
                sheet_list.append(data.sheets()[i])
            template_data_list = list()
            # 将模板文件每个sheet的数据list存入tempLate_data_list列表
            for i_sheet in sheet_list:
                template_data_list.append(i_sheet.row_values(0))
            output_file = xlwt.Workbook()
            # 字体设定
            font = xlwt.Font()
            font.bold = True
            # 边框设定
            borders = xlwt.Borders()
            borders.left = 1
            borders.right = 1
            borders.top = 1
            borders.bottom = 1
            # 背景色设定
            backcolor = xlwt.Pattern()
            backcolor.pattern = xlwt.Pattern.SOLID_PATTERN
            backcolor.pattern_fore_colour = 5
            style = xlwt.XFStyle()
            style.font = font
            style.borders = borders
            style.pattern = backcolor
            output_file_sheet_list = list()
            # 输出文件添加sheet并给予标题,对象存入output_file_sheet_list列表
            for j in range(sheet_count):
                output_file_sheet_list.append(
                    output_file.add_sheet(sheet_name[j],
                                          cell_overwrite_ok=True))
            # j_sheet_num为sheet页的索引
            for j_sheet_num in range(len(sheet_list)):
                # j_sheet_row_index为模板文件template_dataList的索引
                for j_sheet_row_index in range(
                        len(template_data_list[j_sheet_num])):
                    output_file_sheet_list[j_sheet_num].write(
                        0, j_sheet_row_index,
                        template_data_list[j_sheet_num][j_sheet_row_index],
                        style)

            # 数据格式为{"sheet页数":{"列数":[当前添加的数据1,当前添加的数据2]}}
            filter_dict = dict()
            logger.debug("++++++++++++++++++++++++++++++")
            logger.debug(data_list)
            # 以追加方式添加数据
            for data_num in range(len(data_list[0])):
                logger.debug(data_num)
                logger.debug(data_list)
                # 当前sheet的索引
                data_sheet_num = int(data_list[0][data_num]) - 1
                data_row_num = 1
                data_col_num = int(data_list[1][data_num]) - 1
                logger.debug("===================================")
                logger.debug(data_sheet_num)
                logger.debug(data_col_num)
                # 判断当前sheet页数是否在filter_dict中,即当前sheet是否曾经出现过
                if str(data_sheet_num) not in filter_dict:
                    # 当前sheet页数不存在filter_dict,添加对应data_sheet_num字典
                    filter_dict[str(data_sheet_num)] = {}
                    # 增加对应列数的数据list
                    filter_dict[str(data_sheet_num)][str(
                        data_col_num)] = list()
                    # 由于sheet页数第一次出现,故数据也一定第一次出现,所以之列列表中添加值
                    filter_dict[str(data_sheet_num)][str(data_col_num)].append(
                        data_col_num)
                else:
                    # 当前sheet页数存在filter_dict中,判断当前列数是否在列数字典中,即当前列数是否出现过
                    if str(data_col_num) not in filter_dict[str(
                            data_sheet_num)]:
                        # 当前列数未出现过,添加列表
                        filter_dict[str(data_sheet_num)][str(
                            data_col_num)] = list()
                        # 向列数字典列表插数据,但插入数据的当前行数为初始值,即1
                        filter_dict[str(data_sheet_num)][str(
                            data_col_num)].append(data_col_num)
                    else:
                        # 当前列数出现过。向列数字典列表插数据,插入数据的当前行数为总出现的次数
                        filter_dict[str(data_sheet_num)][str(
                            data_col_num)].append(data_col_num)
                        data_row_num = len(filter_dict[str(data_sheet_num)][
                            str(data_col_num)])
                logger.debug(filter_dict)
                data_preview_add = data_list[2][data_num]
                # 向excel中插入数据
                output_file_sheet_list[data_sheet_num].write(
                    data_row_num, data_col_num, data_preview_add)

            output_file.save(str(TimeStamp.time_stamp()) + ".xls")

        except:
            logger.exception("发现错误")