gpt4 book ai didi

Python mod json + urllib2

转载 作者:行者123 更新时间:2023-12-01 05:57:12 26 4
gpt4 key购买 nike

这是Python代码,不起作用且动机未知。

import json, urllib2
url = 'http://twitter.com/#!/search/PAROusuariosSUBTE'
server = urllib2.urlopen(url)
js = json.load(server)
res = js['results']
for espDeRes in res:
espDeRes['from_user']
espDeRes['text']

这是控制台中的错误。

Traceback (most recent call last):
File "pro.py", line 4, in <module>
js = json.load(server)
File "/usr/lib/python2.6/json/__init__.py", line 267, in load
parse_constant=parse_constant, **kw)
File "/usr/lib/python2.6/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.6/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.6/json/decoder.py", line 338, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

有什么想法吗?

谢谢。

最佳答案

我想,您的网址应该是 http://search.twitter.com/search.json?q=PAROusuariosSUBTE 并且应该可以正常工作?

关于Python mod json + urllib2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11895836/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com