Python ssl 'module' 对象没有属性 'SSLContext'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28228214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 02:57:14 来源:igfitidea点击:
ssl 'module' object has no attribute 'SSLContext'
提问by Chandler.Huang
In [1]: import ssl
In [2]: context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
AttributeError Traceback (most recent call last)
<ipython-input-2-13c9bad66150> in <module>()
----> 1 context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
AttributeError: 'module' object has no attribute 'SSLContext'
Python version: 2.7.6
Python版本:2.7.6
采纳答案by Games Brainiac
SSLContext
was introduced in 2.7.9, you're using an old version of Python so it doesn't have this attribute.
SSLContext
是在 2.7.9 中引入的,您使用的是旧版本的 Python,因此它没有此属性。
回答by Shahzeb chohan
You can use code below for Python 2.7.9:
您可以将以下代码用于 Python 2.7.9:
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode=ssl.CERT_NONE