python常用代码以及报错

python连接远程库:
用cx_Oracle连接:
import cx_Oracle
cx_Oracle.connect(‘username’,’pwd’,’IP/HOSTNAME:PORT/TNSNAME’)

No module named ‘StringIO’:
原因:python2到python3 模块的变化
import the io module and use io.StringIO

A possibly useful method of fixing some Python 2 code to also work in Python 3 (caveat emptor):

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

TypeError: string argument expected, got ‘bytes’:
问题出现在使用StringIO上,用BytesIO替代StringIO即可

你可能感兴趣的:(cv中python常见语法)