Python 中文编码问题
2017-04-08 14:36
274 查看
前台:通过下拉框获取检索内容
用下拉框ComboBox获取文字,原本是英文,直接
ComboBox.currentText()就可以了,后来把下拉框内容改成了中文,就出错了
解决方法:
import codes
scene = (ComboBox.currentText()).encode(encoding = 'UTF-8')
后台:根据检索内容进行检索
unicodeMap = {
'车辆': u'\u8f66\u8f86',
'军舰': u'\u519b\u8230',
'船舶': u'\u8239\u8236',
'油罐区': u'\u6cb9\u7f50\u533a',
'飞机': u'\u98de\u673a',
}
例如:
if obj == 'cheliang' or obj == 'vehicle' or obj =='车辆' or obj == '车辆'.decode("utf-8"):
temp_file = TemplateImgPath + 'vehicle.jpg'
self.label = 8
用下拉框ComboBox获取文字,原本是英文,直接
ComboBox.currentText()就可以了,后来把下拉框内容改成了中文,就出错了
'ascii' codec can't encode characters in position
import codes
scene = (ComboBox.currentText()).encode(encoding = 'UTF-8')
后台:根据检索内容进行检索
unicodeMap = {
'车辆': u'\u8f66\u8f86',
'军舰': u'\u519b\u8230',
'船舶': u'\u8239\u8236',
'油罐区': u'\u6cb9\u7f50\u533a',
'飞机': u'\u98de\u673a',
}
例如:
if obj == 'cheliang' or obj == 'vehicle' or obj =='车辆' or obj == '车辆'.decode("utf-8"):
temp_file = TemplateImgPath + 'vehicle.jpg'
self.label = 8
相关文章推荐
- python中文编码问题
- Python MySQLdb 使用utf-8 编码插入中文数据问题
- Python中使用中文及编码问题
- python中中文编码问题
- python2 中文编码问题
- python 中中文编码及输出问题
- python读取csv中所遇到的中文编码问题
- Python中文编码问题
- python 中文编码问题
- python的中文编码问题
- python json 序列化反序列化 和 中文编码问题
- Python 中文编码问题小结
- python中文编码问题深入分析(二):print打印中文异常及显示乱码问题分析与解决
- python json.dumps 中文编码问题
- 有关 Python 2 和 Sublime Text 中文 Unicode 编码问题的分析与理解
- python中文编码问题
- Python处理unicode编码的txt文件(Python中文处理)——解决to_excel()和to_csv()导出文件内容为空的问题
- python2(中文编码问题):UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1
- python的中文编码问题
- 简单解决Python文件中文编码问题