Python 获取两个话题的交集
2014-06-23 06:00
260 查看
CODE:
RESULT:
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-06-28 @author: guaguastd @name: intersection_between_trends.py ''' if __name__ == '__main__': # import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import twitter_login # get the twitter access api twitter_api = twitter_login() # import trend from trend import trend_place # computing the intersection of two sets of trends while 1: woeid1 = int(raw_input("\nInput one wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): ")) if woeid1 == 0: break woeid2 = int(raw_input("\nInput another wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): ")) if woeid2 == 0: break trends1 = trend_place(twitter_api, woeid1) trends2 = trend_place(twitter_api, woeid2) trends_set1 = set([trend['name'] for trend in trends1[0]['trends']]) trends_set2 = set([trend['name'] for trend in trends2[0]['trends']]) common_trend = trends_set1.intersection(trends_set2) print common_trend
RESULT:
Input one wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 1 Input another wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 23424977 set([u'#NEDvsCRC', u'Happy 5th of July', u'#CostaRicavsHolanda', u'Tim Howard in Spanish', u'#GrantLandisDMMe']) Input one wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 0<u> </u>
相关文章推荐
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法
- python两个list获取交集,并集,差集
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法.
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法.
- 使用 Python 获取两个列表的交集、并集、差集的常用方法
- python两个 list 获取交集,并集,差集的方法
- Python求两个文本文件以行为单位的交集、并集与差集的方法
- python获取两个dict的不同
- JavaScript获取两个数组交集的方法
- LINQ获取两个List的交集
- Python求两个list的差集、交集与并集的方法
- Python-Pysvn中获取两个版本之间的diff
- python取两个list的交集并集差集
- Python中获取网页状态码的两个方法
- C# Linq获取两个List或数组的差集交集
- Python求两个list的差集、交集与并集的方法
- Python 获取新浪微博的热门话题 (API)