• 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)
    
  • 相关阅读:
    mysql全文索引
    oracle窗口函数的实战
    数据库的三大范式
    Oracle12cR1 Data Guard 实施文档
    Oracle 11gR2 RAC 删除节点
    Jboss部署文档
    Hexo搭建静态博客踩坑日记(一)
    一行代码引入博客园樱花飘落特效
    Hexo搭建静态博客踩坑日记(二)
    学习axios必知必会(2)~axios基本使用、使用axios前必知细节、axios和实例对象区别、拦截器、取消请求
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348838.html
Copyright © 2020-2023  润新知