我目前每次运行使用 MySQLdb 的 Python 脚本时都会收到警告:
/var/lib/python-support/python2.6/MySQLdb/__init__.py:34:
DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
如果可能的话,我宁愿不要弄乱他们的库。我在 Ubuntu 服务器上。任何人都知道修复该警告消息的简单方法?
谢谢
更新: 根据以下建议和此链接修复它:https://bugzilla.redhat.com/show_bug.cgi?id=505611
import warnings
warnings.filterwarnings('ignore', '.*the sets module is deprecated.*',
DeprecationWarning, 'MySQLdb')
import MySQLdb
最佳答案
在导入 mysql 模块之前执行此操作
import warnings
warnings.filterwarnings(action="ignore", message='the sets module is deprecated')
import sets
关于使用 MysqlDb 时出现 Python 错误 - sets 模块已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2248531/