【问题标题】:Python: PyCurl set URL exceptionPython:PyCurl 设置 URL 异常
【发布时间】:2011-06-27 15:16:43
【问题描述】:

我尝试使用此代码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

我的代码有什么问题?

苏丹

【问题讨论】:

  • 您传递给 c.setopt 的链接参数类型是否正确?

标签: python curl pycurl


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    问题在于它接受字符串,而不是 unicode 对象。去掉 u 和 unicode()。

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

    它会起作用吗?不!

    我使用以下方法来解决这个问题: url=str(url.encode('utf-8'))

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

    【讨论】:

      猜你喜欢
      • 2021-08-13
      • 1970-01-01
      • 2020-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多