Python twitterapi(Tweepy)如何获得确切的术语

Python twitterapi(Tweepy)如何获得确切的术语,python,python-2.7,twitter,tweepy,Python,Python 2.7,Twitter,Tweepy,所以我尝试在twitterapi(tweepy包装器)中搜索包含特定单词的tweet。然而,当搜索单词时,我已经接近结果了。(即搜索“there”,但tweepy返回“there's”。有没有办法用tweepy指定您想要的确切术语 我的部分代码: otherTweet = tweepy.Cursor(api.search, q=word and hashtag, count=1, lang="en").items(1) # searches for words needed to retweet

所以我尝试在twitterapi(tweepy包装器)中搜索包含特定单词的tweet。然而,当搜索单词时,我已经接近结果了。(即搜索“there”,但tweepy返回“there's”。有没有办法用tweepy指定您想要的确切术语

我的部分代码:

otherTweet = tweepy.Cursor(api.search, q=word and hashtag, count=1, lang="en").items(1) # searches for words needed to retweet later
    for a in otherTweet:
        ref = a.text.encode("unicode-escape")
        if "#" in ref and word not in ref.split(" ") or not otherTweet:
            otherTweet = tweepy.Cursor(api.search, q=word, count=1, lang="en").items(1) # Can't find tweet with right hashtag. 
            print "got here"

word和hashtag都是变量,例如word=“hello”hashtag=“#祝福”。我假设我对它们做了一些事情来接收特定的术语。

为了只搜索特定的术语,并删除任何其他术语,您需要在搜索术语周围添加空格。搜索“there”或“there”,而不是“there”


还有更复杂的路由,比如在前后对字符进行二次检查,但这是我在应用程序中找到的最快、最有用的路由。

我尝试过,但似乎没有任何影响。仍然会得到类似“There!”我可能会尝试第二个选项。我从不担心标点符号,我认为这是问题所在(推特字搜索API可能会考虑标点符号作为搜索空白)。如果是这样的话,第二个选项是你的最佳选择,但是应该太难实现。<代码>就是你要找的,应该只需要一个额外的逻辑块就可以修复。是的,你是对的,似乎没有考虑标点符号。最后我不得不拆分。有点烦人,但总比什么都不做要好。