Python:PyCurl设置URL异常

时间:2011-06-27 15:16:43

标签: python curl pycurl

我尝试使用此代码c.setopt(pycurl.URL, link)设置网址,但我收到以下异常


File "/home/sultan/Repository/Django/monitor/app/thread/utils.py", line 164, in perform
    self.proxy_request.setopt(pycurl.URL, u'%s' % unicode(link))
TypeError: invalid arguments to setopt

我的代码出了什么问题?

苏丹

2 个答案:

答案 0 :(得分:9)

问题是它接受字符串,而不是unicode对象。删除u和unicode()。

答案 1 :(得分:2)

  

问题是它接受字符串,而不是unicode对象。删除u和unicode()。

好的,但我有这个网址: http://www.example.com/Pok%C3%A9mon

它会起作用吗?都能跟得上!

我使用以下方法来解决此问题: URL = STR(url.encode( 'UTF-8'))

我可能是错的,所以如果有更好的方法,请纠正我。