Python 获取两个话题的交集
来源:互联网 发布:centos 7.3 lnmp 编辑:程序博客网 时间:2024/05/17 01:28
CODE:
#!/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): 1Input another wowid (1 means WORLD_WOE_ID, 23424977 means US_WOE_ID, 0 to quit): 23424977set([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>
0 0
- Python 获取两个话题的交集
- LINQ获取两个List的交集
- Python 提取两个列表的交集
- 使用 Python 获取两个列表的交集、并集、差集的常用方法
- python两个 list 获取交集,并集,差集的方法.
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法.
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法
- python两个 list 获取交集,并集,差集的方法.
- python取两个list的交集并集差集
- Python -- 两个列表的差集、并集和交集
- Python 求两个 list 的交集和差集
- python 基础编程之求两个数组的交集
- Python 获取Twitter话题 (API)
- 获取两个list的交集和两个list中双方分别不包含的集合
- 求两个数组的交集
- effective c++ 学习新得之 条款2 prefer const,enum, inline to #defines
- 关于单例存在某些问具体的原因
- 文件上传将文件保存为二进制
- linux 函数执行时间统计
- bounds,frame的使用demo
- Python 获取两个话题的交集
- JS计算网页停留时间实例代码(www.jbxue.com)
- 仿iphone原生的时钟程序
- 结构体定义 typedef struct 用法详解和用法小结
- hdu 4267 分组线段树
- 89_leetcode_Search in Rotated Sorted Array II
- ubuntu中配置完美Vim
- 90_leetcode_Unique Binary Search Trees
- 91_leetcode_Unique Binary Search Trees II