zoukankan      html  css  js  c++  java
  • ValueError: unsupported format character 'R' (0x52) at index 358

    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import MySQLdb
    from datetime import datetime
    import cx_Oracle
    import os
    import xlwt
    import sys
    
    reload(sys)
    import time
    
    sys.setdefaultencoding('utf-8')
    os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
    import datetime  # 导入日期时间模块
    
    today = datetime.date.today()  # 获得今天的日期
    yesterday = today - datetime.timedelta(days=1)
    i = 0
    
    
    def get_data():
        applist=['NCBS','LOAN','IBPS']
        for x in applist:
            print x
            mysql="select  /*+parallel(t 8)*/ cnt1 as 失败笔数,(cnt2 - cnt1) as 成功笔数,cnt2 as 总笔数 ,(cnt2 - cnt1)/cnt2 as 成功率 from (select (select count(*) 
                from esb2_trans_log t 
                where t.trans_date >= 
                  trunc(sysdate) 
                  and  t.trans_date <= 
                  trunc(sysdate+1) 
                  and (t.respmsg like '%Read timed out%' or t.respmsg like '%异常%' or 
                  t.respmsg like '%超时%' or t.respmsg like '%通讯%失败%') 
                  and t.logicsystem=%s 
                     and t.esbserviceflowno<>'000000' 
                 and t.flowstepid in ('4','E') ) cnt1 , 
                 ( select  /*+parallel(t 8)*/  count(*) 
                 from esb2_trans_log t 
                 where  t.trans_date >= 
                 trunc(sysdate) 
                 and  t.trans_date <= 
                 trunc(sysdate+1) 
                 and t.logicsystem=%s 
                 and t.flowstepid in ('4','E') 
                 ) cnt2   from dual)" %(x,x)
            print mysql
    get_data()
    
    
    报错:
    C:Python27python.exe C:/Users/Administrator/PycharmProjects/untitled/socket/esb_report_all.py
    NCBS
    Traceback (most recent call last):
      File "C:/Users/Administrator/PycharmProjects/untitled/socket/esb_report_all.py", line 47, in <module>
        get_data()
      File "C:/Users/Administrator/PycharmProjects/untitled/socket/esb_report_all.py", line 45, in get_data
        ) cnt2   from dual)" %(x,x)
    ValueError: unsupported format character 'R' (0x52) at index 358
    
    Process finished with exit code 1
    
    
    
    改成:
    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import MySQLdb
    from datetime import datetime
    import cx_Oracle
    import os
    import xlwt
    import sys
    
    reload(sys)
    import time
    
    sys.setdefaultencoding('utf-8')
    os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
    import datetime  # 导入日期时间模块
    
    today = datetime.date.today()  # 获得今天的日期
    yesterday = today - datetime.timedelta(days=1)
    i = 0
    
    
    def get_data():
        applist=['NCBS','LOAN','IBPS']
        for x in applist:
            print x
            mysql="select  /*+parallel(t 8)*/ cnt1 as 失败笔数,(cnt2 - cnt1) as 成功笔数,cnt2 as 总笔数 ,(cnt2 - cnt1)/cnt2 as 成功率 from (select (select count(*) 
                from esb2_trans_log t 
                where t.trans_date >= 
                  trunc(sysdate) 
                  and  t.trans_date <= 
                  trunc(sysdate+1) 
                  and (t.respmsg like '%%Read timed out%%' or t.respmsg like '%%异常%%' or 
                  t.respmsg like '%%超时%%' or t.respmsg like '%%通讯%%失败%%') 
                  and t.logicsystem=%s 
                     and t.esbserviceflowno<>'000000' 
                 and t.flowstepid in ('4','E') ) cnt1 , 
                 ( select  /*+parallel(t 8)*/  count(*) 
                 from esb2_trans_log t 
                 where  t.trans_date >= 
                 trunc(sysdate) 
                 and  t.trans_date <= 
                 trunc(sysdate+1) 
                 and t.logicsystem=%s 
                 and t.flowstepid in ('4','E') 
                 ) cnt2   from dual)" %(x,x)
            print mysql
    get_data()
    
    
    select /*+parallel(t 8)*/
     cnt1 as 失败笔数,
     (cnt2 - cnt1) as 成功笔数,
     cnt2 as 总笔数,
     (cnt2 - cnt1) / cnt2 as 成功率
      from (select (select count(*)
                      from esb2_trans_log t
                     where t.trans_date >= trunc(sysdate)
                       and t.trans_date <= trunc(sysdate + 1)
                       and (t.respmsg like '%Read timed out%' or
                           t.respmsg like '%异常%' or t.respmsg like '%超时%' or
                           t.respmsg like '%通讯%失败%')
                       and t.logicsystem = NCBS
                       and t.esbserviceflowno <> '000000'
                       and t.flowstepid in ('4', 'E')) cnt1,
                   (select /*+parallel(t 8)*/
                     count(*)
                      from esb2_trans_log t
                     where t.trans_date >= trunc(sysdate)
                       and t.trans_date <= trunc(sysdate + 1)
                       and t.logicsystem = NCBS
                       and t.flowstepid in ('4', 'E')) cnt2
              from dual)
           
            select /*+parallel(t 8)*/
             cnt1 as 失败笔数,
             (cnt2 - cnt1) as 成功笔数,
             cnt2 as 总笔数,
             (cnt2 - cnt1) / cnt2 as 成功率
              from (select (select count(*)
                              from esb2_trans_log t
                             where t.trans_date >= trunc(sysdate)
                               and t.trans_date <= trunc(sysdate + 1)
                               and (t.respmsg like '%Read timed out%' or
                                   t.respmsg like '%异常%' or
                                   t.respmsg like '%超时%' or
                                   t.respmsg like '%通讯%失败%')
                               and t.logicsystem = LOAN
                               and t.esbserviceflowno <> '000000'
                               and t.flowstepid in ('4', 'E')) cnt1,
                           (select /*+parallel(t 8)*/
                             count(*)
                              from esb2_trans_log t
                             where t.trans_date >= trunc(sysdate)
                               and t.trans_date <= trunc(sysdate + 1)
                               and t.logicsystem = LOAN
                               and t.flowstepid in ('4', 'E')) cnt2
                      from dual)
                   
                    select /*+parallel(t 8)*/
                     cnt1 as 失败笔数,
                     (cnt2 - cnt1) as 成功笔数,
                     cnt2 as 总笔数,
                     (cnt2 - cnt1) / cnt2 as 成功率
                      from (select (select count(*)
                                      from esb2_trans_log t
                                     where t.trans_date >= trunc(sysdate)
                                       and t.trans_date <= trunc(sysdate + 1)
                                       and (t.respmsg like '%Read timed out%' or
                                           t.respmsg like '%异常%' or
                                           t.respmsg like '%超时%' or
                                           t.respmsg like '%通讯%失败%')
                                       and t.logicsystem = IBPS
                                       and t.esbserviceflowno <> '000000'
                                       and t.flowstepid in ('4', 'E')) cnt1,
                                   (select /*+parallel(t 8)*/
                                     count(*)
                                      from esb2_trans_log t
                                     where t.trans_date >= trunc(sysdate)
                                       and t.trans_date <= trunc(sysdate + 1)
                                       and t.logicsystem = IBPS
                                       and t.flowstepid in ('4', 'E')) cnt2
                              from dual)
    
  • 相关阅读:
    点分治 / 点分树题目集
    HNOI2019 游记
    WC2019 题目集
    SA / SAM 题目集
    Min_25 筛小结
    NOIP2018 差点退役记
    Atcoder 乱做
    DP及其优化
    计数与概率期望小结
    分库分表之后全局id咋生成?
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348838.html
Copyright © 2011-2022 走看看