V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
shenxj
V2EX  ›  Python

求助各位大神

  •  1
     
  •   shenxj · 2018-12-25 14:21:56 +08:00 · 1481 次点击
    这是一个创建于 1921 天前的主题,其中的信息可能已经有所发展或是发生改变。
    conn = cx_Oracle.connect('dbrtadm/[email protected]:1700/MBSS')
    

    python 中用这个 cx_Oracle 连接数据库报 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 63: invalid continuation byte 这个错误

    之前在本地用 python2 环境是可以用的,现在切换为 python3 环境就不行了,大佬们有遇到过的吗?求助啊

    第 1 条附言  ·  2018-12-25 15:23:03 +08:00
    问题已经解决!原因是本地的 oracle 和 python 版本不匹配,本地的 oracle 版本是 32 位的,python 版本是 64 位的,所以不行,改成 32 位的 python 就可以正常连接了
    2 条回复    2018-12-25 14:42:00 +08:00
    Mnzz0785
        1
    Mnzz0785  
       2018-12-25 14:41:47 +08:00
    py2 和 py3 的字符串不是一种编码格式。
    2 里的字符串默认为二进制数据,编码后是 Unicode 类型
    所以你需要先 encode
    huisezhiyin
        2
    huisezhiyin  
       2018-12-25 14:42:00 +08:00
    这个错误不是编码错误么 试一下这个回答 https://segmentfault.com/a/1190000008318279
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2815 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:56 · PVG 22:56 · LAX 07:56 · JFK 10:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.