python zen (계속 갱신중)
1. get list element in a list of tuples a = [(1, u'abc'), (2, u'def')] # 기존 방법 def _seperate(l_wstnid_and_weight): l_wstnid, l_weight = [], [] for k, w in l_wstnid_and_weight: l_wstnid.append(k) l_weight.append(w) return l_wstnid, l_weight print(_seperate(a)) # 간략하고 쉽게 unzip = list(zip(*a)) print((unzip[0], unzip[1])) 2. zip a = dict(one=1, two=2, three=3) b = {'one': 1, 'two': 2, 'three': 3} c ..