使用Python 3:
>>> from collections import OrderedDict
>>> d1 = OrderedDict([('foo', 'bar')])
>>> d2 = OrderedDict([('foo', 'bar')])
Run Code Online (Sandbox Code Playgroud)
我想检查是否平等:
>>> d1 == d2
True
>>> d1.keys() == d2.keys()
True
Run Code Online (Sandbox Code Playgroud)
但:
>>> d1.values() == d2.values()
False
Run Code Online (Sandbox Code Playgroud)
你知道为什么价值观不平等吗?
我用Python 3.4和3.5进行了测试.
在这个问题之后,我发布了Python-Ideas邮件列表以获得更多详细信息:
https://mail.python.org/pipermail/python-ideas/2015-December/037472.html
我正在尝试在python中使用基本身份验证
auth = requests.post('http://' + hostname, auth=HTTPBasicAuth(user, password))
request = requests.get('http://' + hostname + '/rest/applications')
Run Code Online (Sandbox Code Playgroud)
响应表单auth变量:
<<class 'requests.cookies.RequestsCookieJar'>[<Cookie JSESSIONID=cb10906c6219c07f887dff5312fb for appdynamics/controller>]>
200
CaseInsensitiveDict({'content-encoding': 'gzip', 'x-powered-by': 'JSP/2.2', 'transfer-encoding': 'chunked', 'set-cookie': 'JSESSIONID=cb10906c6219c07f887dff5312fb; Path=/controller; HttpOnly', 'expires': 'Wed, 05 Nov 2014 19:03:37 GMT', 'server': 'nginx/1.1.19', 'connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'max-age=78000', 'date': 'Tue, 04 Nov 2014 21:23:37 GMT', 'content-type': 'text/html;charset=ISO-8859-1'})
Run Code Online (Sandbox Code Playgroud)
但是当我试图从不同的位置获取数据时, - 我有401错误
<<class 'requests.cookies.RequestsCookieJar'>[]>
401
CaseInsensitiveDict({'content-length': '1073', 'x-powered-by': 'Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)', 'expires': 'Thu, 01 …
Run Code Online (Sandbox Code Playgroud)