set 去重 会 破坏 原有list 的元素相对位置
feature_reduce_l = [i if re.search('\d', i) is None else i[0:re.search('\d', i).endpos - 1] for i in feature_l] # set 破坏了顺序 print(feature_reduce_l) print(list(set(feature_reduce_l))) feature_reduce_l = [e for i, e in enumerate(feature_reduce_l) if feature_reduce_l.index(e) == i] print(feature_reduce_l) ['uid', 'age', 'gender', 'marriageStatus', 'education', 'consumptionAbility', 'LBS', 'interest1', 'interest2', 'interest3', 'interest4', 'interest5', 'kw1', 'kw2', 'kw3', 'topic1', 'topic2', 'topic3', 'appIdInstall', 'appIdAction', 'ct', 'os', 'carrier', 'house'] ['uid', 'age', 'gender', 'marriageStatus', 'education', 'consumptionAbility', 'LBS', 'interest', 'interest', 'interest', 'interest', 'interest', 'kw', 'kw', 'kw', 'topic', 'topic', 'topic', 'appIdInstall', 'appIdAction', 'ct', 'os', 'carrier', 'house'] ['uid', 'topic', 'interest', 'education', 'ct', 'carrier', 'consumptionAbility', 'appIdAction', 'age', 'gender', 'appIdInstall', 'os', 'house', 'marriageStatus', 'kw', 'LBS'] ['uid', 'age', 'gender', 'marriageStatus', 'education', 'consumptionAbility', 'LBS', 'interest', 'kw', 'topic', 'appIdInstall', 'appIdAction', 'ct', 'os', 'carrier', 'house']