这是我的密码
consumerKey=" "
consumerSecret=" "
accessToken=" "
accessSecret=" "
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
auth.set_access_token(accessToken,accessSecret)
api = tweepy.API(auth)
customerinfo = api.get_user('@ABC')
print "entities :",customerinfo.entities
输出:
^{pr2}$我怎样才能得到一个变量的url值???在
我试过了客户信息.实体.描述以及customerinfo.entities.url 但它不起作用。在
它不起作用,因为变量“entities”是“dictionary”类型。请看一下:https://docs.python.org/2/library/stdtypes.html部分:5.8。映射类型-dict。您需要通过“key”值获得访问权限,如下所示:
等等。在你问问题之前检查文档通常是一个很好的做法。在
customerinfo entities
属于{方法a)。如果不存在这样的键,将返回
KeyError
。 方法b)。如果不存在这样的键,将返回None
。 因此,方法b)。在字典中没有密钥存在的确认时,更可取。在相关问题 更多 >
编程相关推荐