Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python 2.7 requests.get()返回cookie引发类型错误_Python_Python 2.7_Cookies_Http Request - Fatal编程技术网

python 2.7 requests.get()返回cookie引发类型错误

python 2.7 requests.get()返回cookie引发类型错误,python,python-2.7,cookies,http-request,Python,Python 2.7,Cookies,Http Request,我正在对我们的内部服务器执行一个简单的HTTP请求身份验证,获取cookie,然后点击Cassandra RESTful服务器获取数据。返回cookie时,requests.get()阻塞 我有一个成功提取数据的curl脚本,我更愿意使用纯python中的响应JSON数据 下面有什么线索可以说明我做错了什么?我扔掉了饼干,看起来很好,很像我的卷曲饼干 克雷格 我认为问题出在最后一行: r=requests.get(mylink,cookies=authCookie) 请求假定cookies参

我正在对我们的内部服务器执行一个简单的HTTP请求身份验证,获取cookie,然后点击Cassandra RESTful服务器获取数据。返回cookie时,requests.get()阻塞

我有一个成功提取数据的curl脚本,我更愿意使用纯python中的响应JSON数据

下面有什么线索可以说明我做错了什么?我扔掉了饼干,看起来很好,很像我的卷曲饼干

克雷格



我认为问题出在最后一行:

r=requests.get(mylink,cookies=authCookie)

请求假定
cookies
参数是一个字典,但您正在向它传递字符串对象
authCookie


当请求试图将字符串
authCookie
视为字典时,会出现异常。

谢谢Rikka,所以我使用authCookie作为值,我使用什么字符串作为dict键?我不确定。authCookie的价值是什么?我认为authCookie本身应该包含cookie的键和值,但应该是字符串格式。
import requests
import rtim

# this makes the auth and gets the cookie returned, save the cookie
myAuth = requests.get(rtim.rcas_auth_url, auth=(rtim.username, rtim.password),verify=False)
print myAuth.status_code
authCookie=myAuth.headers['set-cookie']

IXhost='xInternalHostName.com:9990'
mylink='http:/%s/v1/BONDISSUE?format=JSONARRAY&issue.isin=%s' % (IXhost, 'US3133XK4V44')

# chokes on next line .... doesn't like the Cookie format
r = requests.get(mylink, cookies=authCookie)
(Pdb) next
TypeError: 'string indices must be integers, not str'