Python 3.4 弃用警告 convert_charrefs [英] Python 3.4 DeprecationWarning convert_charrefs

查看:31
本文介绍了Python 3.4 弃用警告 convert_charrefs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 shell 中使用 UnitTest:

Using UnitTest in the shell:

python3.4 -m unittest my_test.py -v

我收到了弃用警告

DeprecationWarning: The value of convert_charrefs will become True in 3.5. You are encouraged to set the value explicitly.  super().__init__() ERROR

好像是这样

super().__init__()

触发此 DeprecationWarning.但我找不到任何关于 convert_charrefs 警告的信息.Python 文档中也使用了 used 语句,SO 中有多个示例.

triggers this DeprecationWarning. But I can not find anything about convert_charrefs warning. Also the used statement is used in the Python documentation, and multiple examples in SO.

导致此警告的原因是什么,我该如何解决?谢谢.

What causes this warning, and how can I solve this? Thanks.

推荐答案

convert_charrefs 对应于 HTMLParser.如果您从此类继承,则必须明确指定 convert_charrefs:

convert_charrefs correspond to HTMLParser. If you inherit from this class you must explicitly specify convert_charrefs:

class Foo(HTMLParser): 
  def __init__(self): 
    super().__init__(convert_charrefs=True)

这篇关于Python 3.4 弃用警告 convert_charrefs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆