Linux yum 运行时提示编码问题错误

简介: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

1..报错:

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal


2.解决:


这个报错是编码问题导致的

在文件头加上

# -*- coding:utf-8 -*-


对需要比较的中文字符变量如:

label = label.decode('utf-8')


1.具体实例:

问题展示:

/usr/lib/python2.7/site-packages/yum/misc.py:133: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  return lambda s: s.lower() == pat


1.问题解决:

1 # -*- coding:utf-8 -*-
2 #! /usr/bin/python -tt
3 """
4 Assorted utility functions for yum.
5 """
6
7 import types
8 import os
9 import sys
10 import os.path
11 from cStringIO import StringIO
12 import base64
13 import binascii
14 import struct
15 import re
16 import errno
17 import Errors
18 import constants
19 import pgpmsg
20 import tempfile
21 import glob
22 import pwd
23 import fnmatch
24 import bz2
25 import gzip
26 import shutil
27 import urllib
28 import string
......
124 def compile_pattern(pat, ignore_case=False):
125     """ Compile shell wildcards, return a 'match' function. """
126     if re_glob(pat):
127         try:
128             flags = ignore_case and re.I or 0
129             return re.compile(fnmatch.translate(pat), flags).match
130         except re.error:
131             pass # fall back to exact match
132     if ignore_case:
133         pat = pat.lower()
134         return lambda s: s.lower() == pat.decode('utf-8')
135     return lambda s: s == pat


3。再次测试:

[root@localhost .pyenv]# yum-config-manager –add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
[root@localhost .pyenv]# yum-config-manager --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost .pyenv]#
目录
相关文章
|
20天前
|
Web App开发 存储 Linux
Linux(33)Rockchip RK3568 Ubuntu22.04上通过SSH运行Qt程序和关闭Chrome的密钥提示
Linux(33)Rockchip RK3568 Ubuntu22.04上通过SSH运行Qt程序和关闭Chrome的密钥提示
59 0
|
21天前
|
Linux 开发工具 C语言
Linux的学习之路:7、yum与git
Linux的学习之路:7、yum与git
14 0
|
21天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
33 0
|
1月前
|
Linux Shell 开发工具
Shell的运行原理以及Linux当中的权限问题
Shell的运行原理以及Linux当中的权限问题
35 0
|
1月前
|
监控 Unix Linux
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
34 0
|
1月前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
49 0
|
1月前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
98 0
|
1月前
|
Ubuntu Linux 编译器
【Linux】4. 开发工具的使用(yum/vim)
【Linux】4. 开发工具的使用(yum/vim)
45 2
|
1月前
|
Linux
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
28 0
|
4天前
|
存储 缓存 Ubuntu
Linux:软件包管理器 - yum
Linux:软件包管理器 - yum
21 2