zoukankan      html  css  js  c++  java
  • python 转xe7xbdx97xe5x87xbd 为中文

    [root@yyjk tmp]# cat a1.py 
    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import cx_Oracle
    from pprint import pprint
    import csv
    import time
    import re
    import binascii
    
    conn = cx_Oracle.connect('xxx/xxx@10.5.100.232/tlyy')
    cursor = conn.cursor()
    xsql="select * from tlcb_mon_device a where a.ipaddr='10.3.244.1'"
    r = cursor.execute(xsql)
    print r
    arr=[]
    for x in r:
     print x
     print type(x)
    [root@yyjk tmp]# python a1.py 
    <cx_Oracle.Cursor on <cx_Oracle.Connection to xxx@10.5.100.232/tlyy>>
    ('DP_244.1', 'IBM AIX', '10.3.244.1', 'UTF-8', 'xe7x94xb5xe7xa5xa8xe5x89x8dxe7xbdxaexe4xb8xbbxe6x9cxba', 'ECDS', 'xe7xbdx97xe5x87xbd', '1', 'FTP')
    <type 'tuple'>
    
    
    [root@yyjk tmp]# cat a1.py 
    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import cx_Oracle
    from pprint import pprint
    import csv
    import time
    import re
    import binascii
    
    conn = cx_Oracle.connect('xxx/xxx@10.5.100.232/tlyy')
    cursor = conn.cursor()
    xsql="select * from tlcb_mon_device a where a.ipaddr='10.3.244.1'"
    r = cursor.execute(xsql)
    print r
    arr=[]
    for x in r:
     print x
     print type(x)
     print x.decode('string_escape')
    [root@yyjk tmp]# 
    
    
    [root@yyjk tmp]# python a1.py 
    <cx_Oracle.Cursor on <cx_Oracle.Connection to xxx@10.5.100.232/tlyy>>
    ('DP_244.1', 'IBM AIX', '10.3.244.1', 'UTF-8', 'xe7x94xb5xe7xa5xa8xe5x89x8dxe7xbdxaexe4xb8xbbxe6x9cxba', 'ECDS', 'xe7xbdx97xe5x87xbd', '1', 'FTP')
    <type 'tuple'>
    Traceback (most recent call last):
      File "a1.py", line 19, in <module>
        print x.decode('string_escape')
    AttributeError: 'tuple' object has no attribute 'decode'
    
    
    [root@yyjk tmp]# cat a1.py 
    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import cx_Oracle
    from pprint import pprint
    import csv
    import time
    import re
    import binascii
    
    conn = cx_Oracle.connect('xxx/xxx@10.5.100.232/tlyy')
    cursor = conn.cursor()
    xsql="select * from tlcb_mon_device a where a.ipaddr='10.3.244.1'"
    r = cursor.execute(xsql)
    print r
    arr=[]
    for x in r:
     print x
     print type(x)
     bb=str(x)
     print bb.decode('string_escape')
    [root@yyjk tmp]# python a1.py
    <cx_Oracle.Cursor on <cx_Oracle.Connection to xxx@10.5.100.232/tlyy>>
    ('DP_244.1', 'IBM AIX', '10.3.244.1', 'UTF-8', 'xe7x94xb5xe7xa5xa8xe5x89x8dxe7xbdxaexe4xb8xbbxe6x9cxba', 'ECDS', 'xe7xbdx97xe5x87xbd', '1', 'FTP')
    <type 'tuple'>
    ('DP_244.1', 'IBM AIX', '10.xx', 'UTF-8', 'xx', 'ECDS', 'xx', '1', 'FTP')

  • 相关阅读:
    sublime text 配置本地静态服务器方法
    js中获得当前时间是年份和月份
    如何在Intellij IDEA中拉svn分支?
    快速上手seajs模块化以及案例
    webpack 配置多页面应用的一次尝试
    【Gitlab】gitlab-CI 持续集成以及runner的配置简版
    【vue】elementUI报错:_self.$scopedSlots.default is not a function
    【webpack】webpack多版本控制方案
    vuepress博客主题—vuepress-theme-reco
    reco-fetch
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349249.html
Copyright © 2011-2022 走看看