Re: [問題] 有趣的問題 關於交集與聯集的處理方式

作者: MOONY135 (談無慾)   2016-01-19 11:00:57
※ 引述《busystudent (busystudent)》之銘言:
: hi 我是Bob 第一次在這邊發文,聽說有不少高手臥虎藏龍!
: as title 我爬蟲了一個網站,經過整理得到很多如下面的結果
: ['spanish', 'web2.0', 'e-learning', 'education', 'social', 'spain', 'tools', 'learning', 'google', 'e-learning2.0']
: ['education', 'technology', 'learning', 'classroom', '%22educational%20technology%22', 'google', 'teaching', 'collaboration', 'students', 'web2.0']
: [education]
: [technology]
: 每一個list就是一個人所收藏的標籤,像是a桑收藏第一行的list標籤集,b桑收藏第二行的標籤集等,有很多筆list。
: 我想請問,要如何計算與判斷同時收藏education標籤與technology的人數,以及要如行計算與判斷收藏education或收藏technology的人數
: 我一開始是打算先指定一個標籤education,再使用if判斷是否與目標technology同時出現,可是考慮到人數就又感覺到怪怪的
: 請大家給我一點提示! 謝謝
先存成字典
SAVE_DICT = {"A":"a_LIST", "B":"B_LIST"}
for i in save_dict.keys():
if education in save_dict[i]:
count += 1
大概是這樣吧(存成字典是有可能還要去找說 這些標籤的有哪些人)
作者: SocketAM2 (AM2)   2016-01-19 18:15:00
交集聯集 有什麼不用set的好理由嗎?
作者: MOONY135 (談無慾)   2016-01-19 21:26:00
他是要算個數 SET有辦法算個數嗎

Links booklink

Contact Us: admin [ a t ] ucptt.com