# db = cx_Oracle.connect('用户名','用户密码','ip:端口号/数据库名') #连接数据库
db = cx_Oracle.connect(db_user, db_password, db_conn_str) # 连接数据库
print(db.version) # tq 打印版本看看 显示 11.2.0.3.0
cursor = db.cursor() # 游标操作
#上述基础操作,忽略。。。。,重点是test1()函数中的
def test1():
cursor.execute("select utl_raw.cast_to_raw(dept_name) from dept_dict where dept_code='2113'")
for rawValue in cursor:
# 尝试这些字符集:GB18030,GBK,UTF-8,US-ASCII
print(str(rawValue[0], encoding="GBK"))
if __name__ == '__main__':
test1()
https://codeantenna.com/a/3E0meOcuIq