- """
- python MAC地址去重.py
- """
- #不保持mac行的顺序
- txt=open("mac.bat").readlines()
- re=list(set(txt[1:-2]))+txt[-2:]
- open('mac_new.bat',"w+").writelines(re)
- #方法二 可以保持原有的顺序
- txt=open("mac.bat").readlines()
- results=[]
- [results.append(r) for r in txt if r not in results]
- open("mac_new.bat","w+").writelines(results)
- #该片段来自于http://www.codesnippet.cn/detail/1507201614871.html
来源: http://www.codesnippet.cn/detail/1507201614871.html