python cx_Oracle: UnicodeEncodeError: 'ascii' codec can't encode characters
使用 Python 連線到 Oracle 資料庫執行 INSERT 操作,因為資料中包含 Ã 之類的特殊字元,導致 execute SQL 語句報錯如下:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128)
Python 版本:3.7
指令碼檔案編碼字符集:UTF-8
問題原因:
客戶端需要設定如下環境變數:
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
LANG=AMERICAN_AMERICA.AL32UTF8
Linux 設定方法:
在 .bash_profile 新增如下兩行:
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export
LANG=AMERICAN_AMERICA.AL32UTF8
Windows 設定方法:
直接在環境變數裡面設定
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31560527/viewspace-2659448/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Python——UnicodeEncodeError: 'ascii' codec can't encode/decode charactersPythonUnicodeErrorASCII
- Python3解決UnicodeEncodeError: 'ascii' codec can't encode characters in position 0PythonUnicodeErrorASCII
- 【python爬蟲】用selenium爬時報錯UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\u2022‘Python爬蟲UnicodeError
- day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi...UnicodeError
- Python報錯:UnicodeDecodeError: 'gbk' codec can't decode byte ...PythonUnicodeError
- PIP3安裝報錯nicodeDecodeError: 'ascii' codec can't decode byte 0xc3ErrorASCII
- Python3.7使用pip install xxxx報錯:UnicodeDecodeError: 'gbk' codec can't decode bytePythonUnicodeError
- pip install ... ERROR: UnicodeDecodeError: ‘gbk‘ codec can‘t decode/ python setup.py egg_info CheckErrorUnicodePython
- Python讀取csv檔案出現解碼錯誤UnicodeDecodeError: ‘utf-8‘ codec can‘t decodPythonUnicodeError
- pipenv install error UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in positionErrorUnicode
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 0: invalid continuation byteUnicodeError
- Python讀取檔案時出現UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position xx: 解決方案PythonUnicodeError
- 完美解決stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.ErrorPython
- PyMySQL 獲取資料 'utf-8' codec can't decode byte 0xed in position 2: 錯誤MySql
- python在用pandas對csv檔案處理的時候報UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb6。。。的錯誤PythonUnicodeError
- 解決 Python UnicodeEncodeError 錯誤PythonUnicodeError
- Python str() 引發的 UnicodeEncodeErrorPythonUnicodeError
- TypeError: can‘t concat str to bytesError
- Can't open file: (errno: 24)
- python 列印 ASCII表PythonASCII
- Supervisor 解決 can't find command *
- Mongoose can't update timestampGo
- CSC1003 A2 T3 Ascii ArtASCII
- tensorflow讀取圖片時出現錯誤UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid sUnicodeError
- python ascii int互換PythonASCII
- OSError: [E050] Can‘t find model ‘en_core_web_sm‘. It doesn‘t seem to be a shortcut link, a Python pErrorWebPython
- eslint --fix 報錯 can't not find modulesEsLint
- mysql遇到Variable can’t be set to the value of ‘NULL’MySqlNull
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- Can't load IA 32-bit .dll on a
- multiprocessing pool AttributeError: Can't get attribute 'func'Error
- 如何理解 python UnicodeEncodeError 和 UnicodeDecodeError :python 的 string 和 unicodePythonUnicodeError
- redis : Can't save in background: fork: Cannot allocate memoryRedis
- python資料庫模組-Cx_OraclePython資料庫Oracle
- python str與byte轉換 encode decodePython
- FILESTREAM feature can't be enabled if you use cluster shared volumes
- WIN配置git 配置後失敗 can't be establishedGit
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error