简体   繁体   English

UnicodeDecodeError:'ascii' 编解码器无法解码位置 14 中的字节 0xe2:在 GAE python 中序号不在范围内(128)?

[英]UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14: ordinal not in range(128) in GAE python?

I am using Google Cloud Endpoints with python.我正在将 Google Cloud Endpoints 与 python 一起使用。 I am trying to fetch data from database what it is showing我正在尝试从数据库中获取数据显示的内容

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14: ordinal not in range(128) error.

The field for which I am getting error is varchar with我收到错误的字段是 varchar

"BTTR – oct 01 2014 10:00 AM ESt
Primary issue – Want to activate the kaspersky 
Plan Sold – NA
Any commitment –Call back 
Transferred to tech – NA
Session ID –222479342 
Transaction ID (Order ID) –NA
PDF push on sale call –Na" data. Please help.

This code contains accents.此代码包含重音符号。 Accents are not in ascii but in UTF-8口音不是 ascii 而是 UTF-8

My thoughts are that your DB is in utf8, but your python encoding is set on ascii.我的想法是你的数据库在 utf8 中,但你的 python 编码是在 ascii 上设置的。 You should either set your python idle (if used), your shell (if your trying to print), and your python script to UTF8.您应该将 python 空闲(如果使用)、shell(如果您尝试打印)和 python 脚本设置为 UTF8。

Or convert your code using Unicode data或使用Unicode 数据转换您的代码

def remove_accents(input_str):
    nkfd_form = unicodedata.normalize('NFKD', input_str)
    only_ascii = nkfd_form.encode('ASCII', 'ignore')
    return only_ascii

我通过使用解决了这个问题

decode(encoding='unicode-escape',errors='strict')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 3 UnicodeDecodeError:'ascii'编解码器无法解码位置0中的字节0xe2:序数不在范围内(128) - Python 3 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) Python UnicodeDecodeError:'ascii'编解码器无法解码位置0的字节0xe2:序数不在范围内(128) - Python UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) UnicodeDecodeError:'ascii'编解码器无法解码位置0中的字节0xe2:序号不在范围内(128) - UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) UnicodeDecodeError:“ascii”编解码器无法解码位置 13 中的字节 0xe2:序号不在范围内(128) - UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128) UnicodeDecodeError:'ascii'编解码器无法解码位置35的字节0xe2:序数不在范围内(128) - UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 35: ordinal not in range(128) UnicodeDecodeError:'ascii'编解码器无法解码位置4中的字节0xe2:序数不在范围内(128) - UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 4: ordinal not in range(128) 安装熊猫:UnicodeDecodeError:'ascii'编解码器无法解码位置 72 中的字节 0xe2:序号不在范围内(128) - Installing pandas: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 72: ordinal not in range(128) UnicodeDecodeError:'ascii'编解码器无法解码位置139中的字节0xe2:序数不在范围内(128) - UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 139: ordinal not in range(128) Python UnicodeDecodeError:'ascii'编解码器不能解码不在范围内的字节0xe2序数(128) - Python UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 ordinal not in range(128) UnicodeDecodeError:'ascii'编解码器无法解码位置13的字节0xe2:关于读取文件的序数不在range(128)中 - UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128), regarding reading in files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM