简体   繁体   中英

Setting Cookie using pycurl, getting TypeError('invalid arguments to setopt',)

I am new to python I am trying to send session_id as a cookie using pycurl lib in python. Below is the code line.

reportcurl.setopt(pycurl.COOKIE, session_id) 

Where "session_id" is a string. Not sure what I am doing wrong but it is working on Python version 2.7.2 but I am unable to make it run on Python 2.7.3.

Any idea what could be invalid argument in setopt fuction?

Appeciate for any help. Thanks

Data that an application passes to PycURL, such as via setopt calls, must normally be byte strings appropriately encoded.

Make sure the session_id is in the correct format.

http://pycurl.sourceforge.net/doc/unicode.html

通过编码使其工作

session_id.encode("utf-8")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM