使用 MysqlDb 时出现 Python 错误 - sets 模块已弃用

标签 python mysql

我目前每次运行使用 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/

相关文章:

python - 对一小时内出现的单元格进行分组 - Groupby

python - Django 单元测试客户端响应具有空上下文

python - 如何配置 Django 访问远程 MySQL db django.contrib.sites.RequestSite 模块缺失

php - 在 Laravel 中使用 Eloquent ORM 使用 'not regexp' 执行数据库搜索

mysql - '/' 应用程序中的 umbraco 站点服务器错误

mysql - MySQL 中的列名和表名是否区分大小写?

python - 有没有办法检测 python 程序何时结束?

python - 查找 pandas 列的平均时间

mysql - 如何按时间顺序从两个或多个表中进行选择?

php - mysql查询获取特定日期之间用户的详细信息