zoukankan      html  css  js  c++  java
  • 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']
    

      

  • 相关阅读:
    ubuntu LAMP的安装
    windows中安装liunx虚拟机
    jQuery Responsive OneByOne Slider Plugin
    轮播图收集
    移动端图片延迟加载插件
    图片幻灯插件
    小tip: base64:URL背景图片与web页面性能优化
    基于HTML5的可预览多图片Ajax上传
    字体平滑解决方案
    webstorm scss编译css配置
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9062053.html
Copyright © 2011-2022 走看看