# !/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('system/[email protected]/serv')
cursor = conn.cursor()
xsql='select * from tlcb_mon_device'
r = cursor.execute(xsql)
print r
arr=[]
for x in r:
print x
print x[0]
print len(x[0])
#print x[1]
print x[1].decode('gbk').encode('utf-8')
print len(x[1])
y=x[1].decode('gbk').encode('utf-8')
print len(y)
print type(x)
arr.append(x[0])
arr.append(y)
print '-------------------------------------------------------------------------------------------------'
print arr
print type(arr)
for x in arr:
print x
C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/Django/a21.py
>
('192.168.137.3', '\xb2\xe2\xca\xd4\xd6\xf7\xbb\xfa')
192.168.137.3
13
测试主机
8
12
('192.168.137.4', '\xc9\xfa\xb2\xfa\xd6\xf7\xbb\xfa')
192.168.137.4
13
生产主机
8
12
-------------------------------------------------------------------------------------------------
['192.168.137.3', '\xe6\xb5\x8b\xe8\xaf\x95\xe4\xb8\xbb\xe6\x9c\xba', '192.168.137.4', '\xe7\x94\x9f\xe4\xba\xa7\xe4\xb8\xbb\xe6\x9c\xba']
192.168.137.3
测试主机
192.168.137.4
生产主机
Process finished with exit code 0
python 显示为\xe6\xb5\x8b\xe8\xaf\x95\xe4\xb8\xbb\xe6\x9c\xba,实际取出后正常。