python-AttributeError:“ dict”对象没有属性“ read”
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python-AttributeError:“ dict”对象没有属性“ read”,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2107字,纯文字阅读大概需要4分钟。
内容图文
我对python完全陌生.我无法运行以下代码,因为它引发属性错误.有人可以帮忙吗?
import tweepy
import urllib
import json
api_key = "VdG3NjsNKg49NbNb7GMHiX"
api_secret = "yBGKwe2K3QYk5lDny1eIKiyEQawVLQKX1HbRCTRfA9hK9"
access_token_key = "110456973-H8CAAET5CBoEa6FS4CKmk98XOADnJOsxK45"
access_token_secret = "wPUlfaxs1TFrTlXs2VqJIE5ffAfclhJCWmMlLPncb"
auth = tweepy.auth.OAuthHandler(api_key,api_secret)
auth.set_access_token(access_token_key,access_token_secret)
api=tweepy.API(auth,parser=tweepy.parsers.JSONParser())
results=api.search(q="microsoft",count=100)
print type(results)
print json.load(results)
解决方法:
results=api.search(q="microsoft",count=100)
print type(results)
print json.load(results)
结果在这里已经是字典.
无需将其反序列化为JSON.
参见:tweepy.api.API.search()其内容为:
API.search(q[, lang][, locale][, rpp][, page][, since_id][,
geocode][, show_user])
Returns tweets that match a specified query.
Parameters:
q – the search query string
lang – Restricts tweets to the given language, given by an ISO 639-1 code.
locale – Specify the language of the query you are sending. This is intended for language-specific clients and the default should work in the majority of cases.
rpp – The number of tweets to return per page, up to a max of 100.
page – The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page.
geocode – Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by “latitide,longitude,radius”, where radius units must be specified as either “mi” (miles) or “km” (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.
show_user – When true, prepends “<user>:” to the beginning of the tweet. This is useful for readers that do not display Atom’s author field. The default is false.
Return type:
list of SearchResult objects
注意:“返回类型:”
内容总结
以上是互联网集市为您收集整理的python-AttributeError:“ dict”对象没有属性“ read”全部内容,希望文章能够帮你解决python-AttributeError:“ dict”对象没有属性“ read”所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。