坑爹的 ascii codec can't decode byte 0xc8

来源:互联网 发布:一维动态数组定义 编辑:程序博客网 时间:2024/06/05 21:59

用cx_Oracle 写update 语句,为了给参数加上单引号,所以就直接在 :1 之类的两边加上了 单引号,

结果一直报错 ascii codec can't decode byte 0xc8 之类的,还以为是编码问题,可是用debug看,都是string类型,百思不得其解

后来发现把 :1 :2 :3 之类两边的单引号去掉就可以了。。。。


        currentTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        updateSql ="update entrust set opp_serial_no =:1, report_time = to_date(:2, 'YYYY-MM-DD hh24:mi:ss')," + \
                        " close_time = to_date(:3, 'YYYY-MM-DD hh24:mi:ss'), status = '2'" +\
                        " where serial_no=:4"     

        cursor.execute(updateSql, (serialNumTo,  currentTime,  currentTime,  serialNumFrom))
        cursor.execute(updateSql, (serialNumFrom,  currentTime,  currentTime,  serialNumTo))

囧。。原因就是其实是执行SQL语句错误,但是因为eric4的debug报错没有报最底层的错误,这个还有待研究

原创粉丝点击